source: trunk/src/opengl/mesa/3dfx/fxddtex.c

Last change on this file was 3598, checked in by jeroen, 25 years ago

* empty log message *

File size: 34.2 KB
Line 
1/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
2
3/*
4 * Mesa 3-D graphics library
5 * Version: 3.3
6 *
7 * Copyright (C) 1999 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 *
27 * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
28 * terms stated above.
29 *
30 * Thank you for your contribution, David!
31 *
32 * Please make note of the above copyright/license statement. If you
33 * contributed code or bug fixes to this code under the previous (GNU
34 * Library) license and object to the new license, your code will be
35 * removed at your request. Please see the Mesa docs/COPYRIGHT file
36 * for more information.
37 *
38 * Additional Mesa/3Dfx driver developers:
39 * Daryll Strauss <daryll@precisioninsight.com>
40 * Keith Whitwell <keith@precisioninsight.com>
41 *
42 * See fxapi.h for more revision/author details.
43 */
44
45
46#ifdef HAVE_CONFIG_H
47#include "conf.h"
48#endif
49
50#if defined(FX)
51
52#include "fxdrv.h"
53
54void fxPrintTextureData(tfxTexInfo *ti)
55{
56 fprintf(stderr, "Texture Data:\n");
57 if (ti->tObj) {
58 fprintf(stderr, "\tName: %d\n", ti->tObj->Name);
59 fprintf(stderr, "\tBaseLevel: %d\n", ti->tObj->BaseLevel);
60 fprintf(stderr, "\tSize: %d x %d\n",
61 ti->tObj->Image[ti->tObj->BaseLevel]->Width,
62 ti->tObj->Image[ti->tObj->BaseLevel]->Height);
63 } else
64 fprintf(stderr, "\tName: UNNAMED\n");
65 fprintf(stderr, "\tLast used: %d\n", ti->lastTimeUsed);
66 fprintf(stderr, "\tTMU: %ld\n", ti->whichTMU);
67 fprintf(stderr, "\t%s\n", (ti->isInTM)?"In TMU":"Not in TMU");
68 if (ti->tm[0])
69 fprintf(stderr, "\tMem0: %x-%x\n", ti->tm[0]->startAddr,
70 ti->tm[0]->endAddr);
71 if (ti->tm[1])
72 fprintf(stderr, "\tMem1: %x-%x\n", ti->tm[1]->startAddr,
73 ti->tm[1]->endAddr);
74 fprintf(stderr, "\tMipmaps: %d-%d\n", ti->minLevel, ti->maxLevel);
75 fprintf(stderr, "\tFilters: min %d min %d\n", ti->minFilt, ti->maxFilt);
76 fprintf(stderr, "\tClamps: s %d t %d\n", ti->sClamp, ti->tClamp);
77 fprintf(stderr, "\tScales: s %f t %f\n", ti->sScale, ti->tScale);
78 fprintf(stderr, "\tInt Scales: s %d t %d\n",
79 ti->int_sScale/0x800000, ti->int_tScale/0x800000);
80 fprintf(stderr, "\t%s\n", (ti->fixedPalette)?"Fixed palette":"Non fixed palette");
81 fprintf(stderr, "\t%s\n", (ti->validated)?"Validated":"Not validated");
82}
83
84
85/************************************************************************/
86/*************************** Texture Mapping ****************************/
87/************************************************************************/
88
89static void fxTexInvalidate(GLcontext *ctx, struct gl_texture_object *tObj)
90{
91 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
92 tfxTexInfo *ti;
93
94 fxTMMoveOutTM(fxMesa,tObj); /* TO DO: SLOW but easy to write */
95
96 ti=fxTMGetTexInfo(tObj);
97 ti->validated=GL_FALSE;
98 fxMesa->new_state|=FX_NEW_TEXTURING;
99 ctx->Driver.RenderStart = fxSetupFXUnits;
100}
101
102static tfxTexInfo *fxAllocTexObjData(fxMesaContext fxMesa)
103{
104 tfxTexInfo *ti;
105 int i;
106
107 if(!(ti=(tfxTexInfo *)CALLOC(sizeof(tfxTexInfo)))) {
108 fprintf(stderr,"fx Driver: out of memory !\n");
109 fxCloseHardware();
110 EXIT(-1);
111 }
112
113 ti->validated=GL_FALSE;
114 ti->isInTM=GL_FALSE;
115
116 ti->whichTMU=FX_TMU_NONE;
117
118 ti->tm[FX_TMU0]=NULL;
119 ti->tm[FX_TMU1]=NULL;
120
121 ti->minFilt=GR_TEXTUREFILTER_POINT_SAMPLED;
122 ti->maxFilt=GR_TEXTUREFILTER_BILINEAR;
123
124 ti->sClamp=GR_TEXTURECLAMP_WRAP;
125 ti->tClamp=GR_TEXTURECLAMP_WRAP;
126
127 ti->mmMode=GR_MIPMAP_NEAREST;
128 ti->LODblend=FXFALSE;
129
130 for(i=0;i<MAX_TEXTURE_LEVELS;i++) {
131 ti->mipmapLevel[i].used=GL_FALSE;
132 ti->mipmapLevel[i].data=NULL;
133 }
134
135 return ti;
136}
137
138void fxDDTexBind(GLcontext *ctx, GLenum target, struct gl_texture_object *tObj)
139{
140 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
141 tfxTexInfo *ti;
142
143 if (MESA_VERBOSE&VERBOSE_DRIVER) {
144 fprintf(stderr,"fxmesa: fxDDTexBind(%d,%x)\n",tObj->Name,(GLuint)tObj->DriverData);
145 }
146
147 if(target!=GL_TEXTURE_2D)
148 return;
149
150 if (!tObj->DriverData) {
151 tObj->DriverData=fxAllocTexObjData(fxMesa);
152 }
153
154 ti=fxTMGetTexInfo(tObj);
155
156 fxMesa->texBindNumber++;
157 ti->lastTimeUsed=fxMesa->texBindNumber;
158
159 fxMesa->new_state|=FX_NEW_TEXTURING;
160 ctx->Driver.RenderStart = fxSetupFXUnits;
161}
162
163void fxDDTexEnv(GLcontext *ctx, GLenum target, GLenum pname, const GLfloat *param)
164{
165 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
166
167 if (MESA_VERBOSE&VERBOSE_DRIVER) {
168 if(param)
169 fprintf(stderr,"fxmesa: texenv(%x,%x)\n",pname,(GLint)(*param));
170 else
171 fprintf(stderr,"fxmesa: texenv(%x)\n",pname);
172 }
173
174 /* apply any lod biasing right now */
175 if (pname==GL_TEXTURE_LOD_BIAS_EXT) {
176 grTexLodBiasValue(GR_TMU0,*param);
177
178 if(fxMesa->haveTwoTMUs) {
179 grTexLodBiasValue(GR_TMU1,*param);
180 }
181
182 }
183
184 fxMesa->new_state|=FX_NEW_TEXTURING;
185 ctx->Driver.RenderStart = fxSetupFXUnits;
186}
187
188void fxDDTexParam(GLcontext *ctx, GLenum target, struct gl_texture_object *tObj,
189 GLenum pname, const GLfloat *params)
190{
191 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
192 GLenum param=(GLenum)(GLint)params[0];
193 tfxTexInfo *ti;
194
195 if (MESA_VERBOSE&VERBOSE_DRIVER) {
196 fprintf(stderr,"fxmesa: fxDDTexParam(%d,%x,%x,%x)\n",tObj->Name,(GLuint)tObj->DriverData,pname,param);
197 }
198
199 if(target!=GL_TEXTURE_2D)
200 return;
201
202 if (!tObj->DriverData)
203 tObj->DriverData=fxAllocTexObjData(fxMesa);
204
205 ti=fxTMGetTexInfo(tObj);
206
207 switch(pname) {
208
209 case GL_TEXTURE_MIN_FILTER:
210 switch(param) {
211 case GL_NEAREST:
212 ti->mmMode=GR_MIPMAP_DISABLE;
213 ti->minFilt=GR_TEXTUREFILTER_POINT_SAMPLED;
214 ti->LODblend=FXFALSE;
215 break;
216 case GL_LINEAR:
217 ti->mmMode=GR_MIPMAP_DISABLE;
218 ti->minFilt=GR_TEXTUREFILTER_BILINEAR;
219 ti->LODblend=FXFALSE;
220 break;
221 case GL_NEAREST_MIPMAP_NEAREST:
222 ti->mmMode=GR_MIPMAP_NEAREST;
223 ti->minFilt=GR_TEXTUREFILTER_POINT_SAMPLED;
224 ti->LODblend=FXFALSE;
225 break;
226 case GL_LINEAR_MIPMAP_NEAREST:
227 ti->mmMode=GR_MIPMAP_NEAREST;
228 ti->minFilt=GR_TEXTUREFILTER_BILINEAR;
229 ti->LODblend=FXFALSE;
230 break;
231 case GL_NEAREST_MIPMAP_LINEAR:
232 if(fxMesa->haveTwoTMUs) {
233 ti->mmMode=GR_MIPMAP_NEAREST;
234 ti->LODblend=FXTRUE;
235 } else {
236 ti->mmMode=GR_MIPMAP_NEAREST_DITHER;
237 ti->LODblend=FXFALSE;
238 }
239 ti->minFilt=GR_TEXTUREFILTER_POINT_SAMPLED;
240 break;
241 case GL_LINEAR_MIPMAP_LINEAR:
242 if(fxMesa->haveTwoTMUs) {
243 ti->mmMode=GR_MIPMAP_NEAREST;
244 ti->LODblend=FXTRUE;
245 } else {
246 ti->mmMode=GR_MIPMAP_NEAREST_DITHER;
247 ti->LODblend=FXFALSE;
248 }
249 ti->minFilt=GR_TEXTUREFILTER_BILINEAR;
250 break;
251 default:
252 break;
253 }
254 fxTexInvalidate(ctx,tObj);
255 break;
256
257 case GL_TEXTURE_MAG_FILTER:
258 switch(param) {
259 case GL_NEAREST:
260 ti->maxFilt=GR_TEXTUREFILTER_POINT_SAMPLED;
261 break;
262 case GL_LINEAR:
263 ti->maxFilt=GR_TEXTUREFILTER_BILINEAR;
264 break;
265 default:
266 break;
267 }
268 fxTexInvalidate(ctx,tObj);
269 break;
270
271 case GL_TEXTURE_WRAP_S:
272 switch(param) {
273 case GL_CLAMP:
274 ti->sClamp=GR_TEXTURECLAMP_CLAMP;
275 break;
276 case GL_REPEAT:
277 ti->sClamp=GR_TEXTURECLAMP_WRAP;
278 break;
279 default:
280 break;
281 }
282 fxMesa->new_state|=FX_NEW_TEXTURING;
283 ctx->Driver.RenderStart = fxSetupFXUnits;
284 break;
285
286 case GL_TEXTURE_WRAP_T:
287 switch(param) {
288 case GL_CLAMP:
289 ti->tClamp=GR_TEXTURECLAMP_CLAMP;
290 break;
291 case GL_REPEAT:
292 ti->tClamp=GR_TEXTURECLAMP_WRAP;
293 break;
294 default:
295 break;
296 }
297 fxMesa->new_state|=FX_NEW_TEXTURING;
298 ctx->Driver.RenderStart = fxSetupFXUnits;
299 break;
300
301 case GL_TEXTURE_BORDER_COLOR:
302 /* TO DO */
303 break;
304
305 case GL_TEXTURE_MIN_LOD:
306 /* TO DO */
307 break;
308 case GL_TEXTURE_MAX_LOD:
309 /* TO DO */
310 break;
311 case GL_TEXTURE_BASE_LEVEL:
312 fxTexInvalidate(ctx,tObj);
313 break;
314 case GL_TEXTURE_MAX_LEVEL:
315 fxTexInvalidate(ctx,tObj);
316 break;
317
318 default:
319 break;
320 }
321}
322
323void fxDDTexDel(GLcontext *ctx, struct gl_texture_object *tObj)
324{
325 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
326 tfxTexInfo *ti=fxTMGetTexInfo(tObj);
327
328 if (MESA_VERBOSE&VERBOSE_DRIVER) {
329 fprintf(stderr,"fxmesa: fxDDTexDel(%d,%x)\n",tObj->Name,(GLuint)ti);
330 }
331
332 if(!ti)
333 return;
334
335 fxTMFreeTexture(fxMesa,tObj);
336
337 FREE(ti);
338 tObj->DriverData=NULL;
339
340 ctx->NewState|=NEW_TEXTURING;
341}
342
343void fxDDTexPalette(GLcontext *ctx, struct gl_texture_object *tObj)
344{
345 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
346 int i;
347 FxU32 r,g,b,a;
348 tfxTexInfo *ti;
349
350 if(tObj) {
351 if (MESA_VERBOSE&VERBOSE_DRIVER) {
352 fprintf(stderr,"fxmesa: fxDDTexPalette(%d,%x)\n",tObj->Name,(GLuint)tObj->DriverData);
353 }
354
355 if(tObj->Palette.Format!=GL_RGBA) {
356#ifndef FX_SILENT
357 fprintf(stderr,"fx Driver: unsupported palette format in texpalette()\n");
358#endif
359 return;
360 }
361
362 if(tObj->Palette.Size>256) {
363#ifndef FX_SILENT
364 fprintf(stderr,"fx Driver: unsupported palette size in texpalette()\n");
365#endif
366 return;
367 }
368
369 if (!tObj->DriverData)
370 tObj->DriverData=fxAllocTexObjData(fxMesa);
371
372 ti=fxTMGetTexInfo(tObj);
373
374 for(i=0;i<tObj->Palette.Size;i++) {
375 r=tObj->Palette.Table[i*4];
376 g=tObj->Palette.Table[i*4+1];
377 b=tObj->Palette.Table[i*4+2];
378 a=tObj->Palette.Table[i*4+3];
379 ti->palette.data[i]=(a<<24)|(r<<16)|(g<<8)|b;
380 }
381
382 fxTexInvalidate(ctx,tObj);
383 } else {
384 if (MESA_VERBOSE&VERBOSE_DRIVER) {
385 fprintf(stderr,"fxmesa: fxDDTexPalette(global)\n");
386 }
387 if(ctx->Texture.Palette.Format!=GL_RGBA) {
388#ifndef FX_SILENT
389 fprintf(stderr,"fx Driver: unsupported palette format in texpalette()\n");
390#endif
391 return;
392 }
393
394 if(ctx->Texture.Palette.Size>256) {
395#ifndef FX_SILENT
396 fprintf(stderr,"fx Driver: unsupported palette size in texpalette()\n");
397#endif
398 return;
399 }
400
401 for(i=0;i<ctx->Texture.Palette.Size;i++) {
402 r=ctx->Texture.Palette.Table[i*4];
403 g=ctx->Texture.Palette.Table[i*4+1];
404 b=ctx->Texture.Palette.Table[i*4+2];
405 a=ctx->Texture.Palette.Table[i*4+3];
406 fxMesa->glbPalette.data[i]=(a<<24)|(r<<16)|(g<<8)|b;
407 }
408
409 fxMesa->new_state|=FX_NEW_TEXTURING;
410 ctx->Driver.RenderStart = fxSetupFXUnits;
411 }
412}
413
414void fxDDTexUseGlbPalette(GLcontext *ctx, GLboolean state)
415{
416 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
417
418 if (MESA_VERBOSE&VERBOSE_DRIVER) {
419 fprintf(stderr,"fxmesa: fxDDTexUseGlbPalette(%d)\n",state);
420 }
421
422 if(state) {
423 fxMesa->haveGlobalPaletteTexture=1;
424
425 FX_grTexDownloadTable(GR_TMU0,GR_TEXTABLE_PALETTE,&(fxMesa->glbPalette));
426 if (fxMesa->haveTwoTMUs)
427 FX_grTexDownloadTable(GR_TMU1,GR_TEXTABLE_PALETTE,&(fxMesa->glbPalette));
428 } else {
429 fxMesa->haveGlobalPaletteTexture=0;
430
431 if((ctx->Texture.Unit[0].Current==ctx->Texture.Unit[0].CurrentD[2]) &&
432 (ctx->Texture.Unit[0].Current!=NULL)) {
433 struct gl_texture_object *tObj=ctx->Texture.Unit[0].Current;
434
435 if (!tObj->DriverData)
436 tObj->DriverData=fxAllocTexObjData(fxMesa);
437
438 fxTexInvalidate(ctx,tObj);
439 }
440 }
441}
442
443static int logbase2(int n)
444{
445 GLint i = 1;
446 GLint log2 = 0;
447
448 if (n<0) {
449 return -1;
450 }
451
452 while (n > i) {
453 i *= 2;
454 log2++;
455 }
456 if (i != n) {
457 return -1;
458 }
459 else {
460 return log2;
461 }
462}
463
464/* Need different versions for different cpus.
465 */
466#define INT_TRICK(l2) (0x800000 * l2)
467
468
469int fxTexGetInfo(int w, int h, GrLOD_t *lodlevel, GrAspectRatio_t *ar,
470 float *sscale, float *tscale,
471 int *i_sscale, int *i_tscale,
472 int *wscale, int *hscale)
473{
474
475 static GrLOD_t lod[9]={GR_LOD_256,GR_LOD_128,GR_LOD_64,GR_LOD_32,
476 GR_LOD_16,GR_LOD_8,GR_LOD_4,GR_LOD_2,GR_LOD_1};
477
478 int logw,logh,ws,hs;
479 GrLOD_t l;
480 GrAspectRatio_t aspectratio;
481 float s,t;
482 int is,it;
483
484 logw=logbase2(w);
485 logh=logbase2(h);
486
487 switch(logw-logh) {
488 case 0:
489 aspectratio=GR_ASPECT_1x1;
490 l=lod[8-logw];
491 s=t=256.0f;
492 is=it=INT_TRICK(8);
493 ws=hs=1;
494 break;
495 case 1:
496 aspectratio=GR_ASPECT_2x1;
497 l=lod[8-logw];
498 s=256.0f;
499 t=128.0f;
500 is=INT_TRICK(8);it=INT_TRICK(7);
501 ws=1;
502 hs=1;
503 break;
504 case 2:
505 aspectratio=GR_ASPECT_4x1;
506 l=lod[8-logw];
507 s=256.0f;
508 t=64.0f;
509 is=INT_TRICK(8);it=INT_TRICK(6);
510 ws=1;
511 hs=1;
512 break;
513 case 3:
514 aspectratio=GR_ASPECT_8x1;
515 l=lod[8-logw];
516 s=256.0f;
517 t=32.0f;
518 is=INT_TRICK(8);it=INT_TRICK(5);
519 ws=1;
520 hs=1;
521 break;
522 case 4:
523 aspectratio=GR_ASPECT_8x1;
524 l=lod[8-logw];
525 s=256.0f;
526 t=32.0f;
527 is=INT_TRICK(8);it=INT_TRICK(5);
528 ws=1;
529 hs=2;
530 break;
531 case 5:
532 aspectratio=GR_ASPECT_8x1;
533 l=lod[8-logw];
534 s=256.0f;
535 t=32.0f;
536 is=INT_TRICK(8);it=INT_TRICK(5);
537 ws=1;
538 hs=4;
539 break;
540 case 6:
541 aspectratio=GR_ASPECT_8x1;
542 l=lod[8-logw];
543 s=256.0f;
544 t=32.0f;
545 is=INT_TRICK(8);it=INT_TRICK(5);
546 ws=1;
547 hs=8;
548 break;
549 case 7:
550 aspectratio=GR_ASPECT_8x1;
551 l=lod[8-logw];
552 s=256.0f;
553 t=32.0f;
554 is=INT_TRICK(8);it=INT_TRICK(5);
555 ws=1;
556 hs=16;
557 break;
558 case 8:
559 aspectratio=GR_ASPECT_8x1;
560 l=lod[8-logw];
561 s=256.0f;
562 t=32.0f;
563 is=INT_TRICK(8);it=INT_TRICK(5);
564 ws=1;
565 hs=32;
566 break;
567 case -1:
568 aspectratio=GR_ASPECT_1x2;
569 l=lod[8-logh];
570 s=128.0f;
571 t=256.0f;
572 is=INT_TRICK(7);it=INT_TRICK(8);
573 ws=1;
574 hs=1;
575 break;
576 case -2:
577 aspectratio=GR_ASPECT_1x4;
578 l=lod[8-logh];
579 s=64.0f;
580 t=256.0f;
581 is=INT_TRICK(6);it=INT_TRICK(8);
582 ws=1;
583 hs=1;
584 break;
585 case -3:
586 aspectratio=GR_ASPECT_1x8;
587 l=lod[8-logh];
588 s=32.0f;
589 t=256.0f;
590 is=INT_TRICK(5);it=INT_TRICK(8);
591 ws=1;
592 hs=1;
593 break;
594 case -4:
595 aspectratio=GR_ASPECT_1x8;
596 l=lod[8-logh];
597 s=32.0f;
598 t=256.0f;
599 is=INT_TRICK(5);it=INT_TRICK(8);
600 ws=2;
601 hs=1;
602 break;
603 case -5:
604 aspectratio=GR_ASPECT_1x8;
605 l=lod[8-logh];
606 s=32.0f;
607 t=256.0f;
608 is=INT_TRICK(5);it=INT_TRICK(8);
609 ws=4;
610 hs=1;
611 break;
612 case -6:
613 aspectratio=GR_ASPECT_1x8;
614 l=lod[8-logh];
615 s=32.0f;
616 t=256.0f;
617 is=INT_TRICK(5);it=INT_TRICK(8);
618 ws=8;
619 hs=1;
620 break;
621 case -7:
622 aspectratio=GR_ASPECT_1x8;
623 l=lod[8-logh];
624 s=32.0f;
625 t=256.0f;
626 is=INT_TRICK(5);it=INT_TRICK(8);
627 ws=16;
628 hs=1;
629 break;
630 case -8:
631 aspectratio=GR_ASPECT_1x8;
632 l=lod[8-logh];
633 s=32.0f;
634 t=256.0f;
635 is=INT_TRICK(5);it=INT_TRICK(8);
636 ws=32;
637 hs=1;
638 break;
639 default:
640 return 0;
641 break;
642 }
643
644 if(lodlevel)
645 (*lodlevel)=l;
646
647 if(ar)
648 (*ar)=aspectratio;
649
650 if(sscale)
651 (*sscale)=s;
652
653 if(tscale)
654 (*tscale)=t;
655
656 if(wscale)
657 (*wscale)=ws;
658
659 if(hscale)
660 (*hscale)=hs;
661
662 if (i_sscale)
663 *i_sscale = is;
664
665 if (i_tscale)
666 *i_tscale = it;
667
668
669 return 1;
670}
671
672/*
673 * Given an OpenGL internal texture format, return the corresponding
674 * Glide internal texture format and base texture format.
675 */
676void fxTexGetFormat(GLenum glformat, GrTextureFormat_t *tfmt, GLint *ifmt)
677{
678 switch(glformat) {
679 case 1:
680 case GL_LUMINANCE:
681 case GL_LUMINANCE4:
682 case GL_LUMINANCE8:
683 case GL_LUMINANCE12:
684 case GL_LUMINANCE16:
685 if(tfmt)
686 (*tfmt)=GR_TEXFMT_INTENSITY_8;
687 if(ifmt)
688 (*ifmt)=GL_LUMINANCE;
689 break;
690 case 2:
691 case GL_LUMINANCE_ALPHA:
692 case GL_LUMINANCE4_ALPHA4:
693 case GL_LUMINANCE6_ALPHA2:
694 case GL_LUMINANCE8_ALPHA8:
695 case GL_LUMINANCE12_ALPHA4:
696 case GL_LUMINANCE12_ALPHA12:
697 case GL_LUMINANCE16_ALPHA16:
698 if(tfmt)
699 (*tfmt)=GR_TEXFMT_ALPHA_INTENSITY_88;
700 if(ifmt)
701 (*ifmt)=GL_LUMINANCE_ALPHA;
702 break;
703 case GL_INTENSITY:
704 case GL_INTENSITY4:
705 case GL_INTENSITY8:
706 case GL_INTENSITY12:
707 case GL_INTENSITY16:
708 if(tfmt)
709 (*tfmt)=GR_TEXFMT_ALPHA_8;
710 if(ifmt)
711 (*ifmt)=GL_INTENSITY;
712 break;
713 case GL_ALPHA:
714 case GL_ALPHA4:
715 case GL_ALPHA8:
716 case GL_ALPHA12:
717 case GL_ALPHA16:
718 if(tfmt)
719 (*tfmt)=GR_TEXFMT_ALPHA_8;
720 if(ifmt)
721 (*ifmt)=GL_ALPHA;
722 break;
723 case 3:
724 case GL_RGB:
725 case GL_R3_G3_B2:
726 case GL_RGB4:
727 case GL_RGB5:
728 case GL_RGB8:
729 case GL_RGB10:
730 case GL_RGB12:
731 case GL_RGB16:
732 if(tfmt)
733 (*tfmt)=GR_TEXFMT_RGB_565;
734 if(ifmt)
735 (*ifmt)=GL_RGB;
736 break;
737 case 4:
738 case GL_RGBA:
739 case GL_RGBA2:
740 case GL_RGBA4:
741 case GL_RGBA8:
742 case GL_RGB10_A2:
743 case GL_RGBA12:
744 case GL_RGBA16:
745 if(tfmt)
746 (*tfmt)=GR_TEXFMT_ARGB_4444;
747 if(ifmt)
748 (*ifmt)=GL_RGBA;
749 break;
750 case GL_RGB5_A1:
751 if(tfmt)
752 (*tfmt)=GR_TEXFMT_ARGB_1555;
753 if(ifmt)
754 (*ifmt)=GL_RGBA;
755 break;
756 case GL_COLOR_INDEX:
757 case GL_COLOR_INDEX1_EXT:
758 case GL_COLOR_INDEX2_EXT:
759 case GL_COLOR_INDEX4_EXT:
760 case GL_COLOR_INDEX8_EXT:
761 case GL_COLOR_INDEX12_EXT:
762 case GL_COLOR_INDEX16_EXT:
763 if(tfmt)
764 (*tfmt)=GR_TEXFMT_P_8;
765 if(ifmt)
766 (*ifmt)=GL_RGBA;
767 break;
768 default:
769 fprintf(stderr,"fx Driver: unsupported internalFormat in fxTexGetFormat()\n");
770 fxCloseHardware();
771 EXIT(-1);
772 break;
773 }
774}
775
776static int fxIsTexSupported(GLenum target, GLint internalFormat,
777 const struct gl_texture_image *image)
778{
779 if(target!=GL_TEXTURE_2D)
780 return GL_FALSE;
781
782 switch(internalFormat) {
783 case GL_INTENSITY:
784 case GL_INTENSITY4:
785 case GL_INTENSITY8:
786 case GL_INTENSITY12:
787 case GL_INTENSITY16:
788 case 1:
789 case GL_LUMINANCE:
790 case GL_LUMINANCE4:
791 case GL_LUMINANCE8:
792 case GL_LUMINANCE12:
793 case GL_LUMINANCE16:
794 case 2:
795 case GL_LUMINANCE_ALPHA:
796 case GL_LUMINANCE4_ALPHA4:
797 case GL_LUMINANCE6_ALPHA2:
798 case GL_LUMINANCE8_ALPHA8:
799 case GL_LUMINANCE12_ALPHA4:
800 case GL_LUMINANCE12_ALPHA12:
801 case GL_LUMINANCE16_ALPHA16:
802 case GL_ALPHA:
803 case GL_ALPHA4:
804 case GL_ALPHA8:
805 case GL_ALPHA12:
806 case GL_ALPHA16:
807 case 3:
808 case GL_RGB:
809 case GL_R3_G3_B2:
810 case GL_RGB4:
811 case GL_RGB5:
812 case GL_RGB8:
813 case GL_RGB10:
814 case GL_RGB12:
815 case GL_RGB16:
816 case 4:
817 case GL_RGBA:
818 case GL_RGBA2:
819 case GL_RGBA4:
820 case GL_RGB5_A1:
821 case GL_RGBA8:
822 case GL_RGB10_A2:
823 case GL_RGBA12:
824 case GL_RGBA16:
825 case GL_COLOR_INDEX:
826 case GL_COLOR_INDEX1_EXT:
827 case GL_COLOR_INDEX2_EXT:
828 case GL_COLOR_INDEX4_EXT:
829 case GL_COLOR_INDEX8_EXT:
830 case GL_COLOR_INDEX12_EXT:
831 case GL_COLOR_INDEX16_EXT:
832 break;
833 default:
834 return GL_FALSE;
835 }
836
837 if(image->Width>256)
838 return GL_FALSE;
839
840 if(image->Height>256)
841 return GL_FALSE;
842
843 if(!fxTexGetInfo(image->Width,image->Height,NULL,NULL,NULL,NULL,NULL,NULL,
844 NULL,NULL))
845 return GL_FALSE;
846
847 return GL_TRUE;
848}
849
850static void fxTexBuildImageMap(const struct gl_texture_image *image,
851 GLint internalFormat, unsigned short **dest,
852 GLboolean *istranslate)
853{
854 unsigned short *src;
855 unsigned char *data;
856 int x,y,w,h,wscale,hscale,idx;
857
858 fxTexGetInfo(image->Width,image->Height,NULL,NULL,NULL,NULL,NULL,NULL,
859 &wscale,&hscale);
860 w=image->Width*wscale;
861 h=image->Height*hscale;
862
863 data=image->Data;
864 switch(internalFormat) {
865 case GL_INTENSITY:
866 case GL_INTENSITY4:
867 case GL_INTENSITY8:
868 case GL_INTENSITY12:
869 case GL_INTENSITY16:
870 case 1:
871 case GL_LUMINANCE:
872 case GL_LUMINANCE4:
873 case GL_LUMINANCE8:
874 case GL_LUMINANCE12:
875 case GL_LUMINANCE16:
876 case GL_ALPHA:
877 case GL_ALPHA4:
878 case GL_ALPHA8:
879 case GL_ALPHA12:
880 case GL_ALPHA16:
881 case GL_COLOR_INDEX:
882 case GL_COLOR_INDEX1_EXT:
883 case GL_COLOR_INDEX2_EXT:
884 case GL_COLOR_INDEX4_EXT:
885 case GL_COLOR_INDEX8_EXT:
886 case GL_COLOR_INDEX12_EXT:
887 case GL_COLOR_INDEX16_EXT:
888 /* Optimized for GLQuake */
889
890 if(wscale==hscale==1) {
891 (*istranslate)=GL_FALSE;
892
893 (*dest)=(unsigned short *)data;
894 } else {
895 unsigned char *srcb;
896
897 (*istranslate)=GL_TRUE;
898
899 if(!(*dest)) {
900 if(!((*dest)=src=(unsigned short *)MALLOC(sizeof(unsigned char)*w*h))) {
901 fprintf(stderr,"fx Driver: out of memory !\n");
902 fxCloseHardware();
903 EXIT(-1);
904 }
905 } else
906 src=(*dest);
907
908 srcb=(unsigned char *)src;
909
910 for(y=0;y<h;y++)
911 for(x=0;x<w;x++) {
912 idx=(x/wscale+(y/hscale)*(w/wscale));
913 srcb[x+y*w]=data[idx];
914 }
915 }
916 break;
917 case 2:
918 case GL_LUMINANCE_ALPHA:
919 case GL_LUMINANCE4_ALPHA4:
920 case GL_LUMINANCE6_ALPHA2:
921 case GL_LUMINANCE8_ALPHA8:
922 case GL_LUMINANCE12_ALPHA4:
923 case GL_LUMINANCE12_ALPHA12:
924 case GL_LUMINANCE16_ALPHA16:
925 (*istranslate)=GL_TRUE;
926
927 if(!(*dest)) {
928 if(!((*dest)=src=(unsigned short *)MALLOC(sizeof(unsigned short)*w*h))) {
929 fprintf(stderr,"fx Driver: out of memory !\n");
930 fxCloseHardware();
931 EXIT(-1);
932 }
933 } else
934 src=(*dest);
935
936 if(wscale==hscale==1) {
937 int i=0;
938 int length=h*w;
939 unsigned short a,l;
940
941 while(i++<length) {
942 l=*data++;
943 a=*data++;
944
945 *src++=(a << 8) | l;
946 }
947 } else {
948 unsigned short a,l;
949
950 for(y=0;y<h;y++)
951 for(x=0;x<w;x++) {
952 idx=(x/wscale+(y/hscale)*(w/wscale))*2;
953 l=data[idx];
954 a=data[idx+1];
955
956 src[x+y*w]=(a << 8) | l;
957 }
958 }
959 break;
960 case 3:
961 case GL_RGB:
962 case GL_R3_G3_B2:
963 case GL_RGB4:
964 case GL_RGB5:
965 case GL_RGB8:
966 case GL_RGB10:
967 case GL_RGB12:
968 case GL_RGB16:
969 (*istranslate)=GL_TRUE;
970
971 if(!(*dest)) {
972 if(!((*dest)=src=(unsigned short *)MALLOC(sizeof(unsigned short)*w*h))) {
973 fprintf(stderr,"fx Driver: out of memory !\n");
974 fxCloseHardware();
975 EXIT(-1);
976 }
977 } else
978 src=(*dest);
979
980 if(wscale==hscale==1) {
981 int i=0;
982 int length=h*w;
983 unsigned int r,g,b;
984
985 while(i++<length) {
986 r=*data++;
987 g=*data++;
988 b=*data++;
989
990 *src++=((0xf8 & r) << (11-3)) |
991 ((0xfc & g) << (5-3+1)) |
992 ((0xf8 & b) >> 3);
993 }
994 } else {
995 unsigned int r,g,b;
996
997 for(y=0;y<h;y++)
998 for(x=0;x<w;x++) {
999 idx=(x/wscale+(y/hscale)*(w/wscale))*3;
1000 r=data[idx];
1001 g=data[idx+1];
1002 b=data[idx+2];
1003
1004 src[x+y*w]=((0xf8 & r) << (11-3)) |
1005 ((0xfc & g) << (5-3+1)) |
1006 ((0xf8 & b) >> 3);
1007 }
1008 }
1009 break;
1010 case 4:
1011 case GL_RGBA:
1012 case GL_RGBA2:
1013 case GL_RGBA4:
1014 case GL_RGBA8:
1015 case GL_RGB10_A2:
1016 case GL_RGBA12:
1017 case GL_RGBA16:
1018 (*istranslate)=GL_TRUE;
1019
1020 if(!(*dest)) {
1021 if(!((*dest)=src=(unsigned short *)MALLOC(sizeof(unsigned short)*w*h))) {
1022 fprintf(stderr,"fx Driver: out of memory !\n");
1023 fxCloseHardware();
1024 EXIT(-1);
1025 }
1026 } else
1027 src=(*dest);
1028
1029 if(wscale==hscale==1) {
1030 int i=0;
1031 int length=h*w;
1032 unsigned int r,g,b,a;
1033
1034 while(i++<length) {
1035 r=*data++;
1036 g=*data++;
1037 b=*data++;
1038 a=*data++;
1039
1040 *src++=((0xf0 & a) << 8) |
1041 ((0xf0 & r) << 4) |
1042 (0xf0 & g) |
1043 ((0xf0 & b) >> 4);
1044 }
1045 } else {
1046 unsigned int r,g,b,a;
1047
1048 for(y=0;y<h;y++)
1049 for(x=0;x<w;x++) {
1050 idx=(x/wscale+(y/hscale)*(w/wscale))*4;
1051 r=data[idx];
1052 g=data[idx+1];
1053 b=data[idx+2];
1054 a=data[idx+3];
1055
1056 src[x+y*w]=((0xf0 & a) << 8) |
1057 ((0xf0 & r) << 4) |
1058 (0xf0 & g) |
1059 ((0xf0 & b) >> 4);
1060 }
1061 }
1062 break;
1063 case GL_RGB5_A1:
1064 (*istranslate)=GL_TRUE;
1065
1066 if(!(*dest)) {
1067 if(!((*dest)=src=(unsigned short *)malloc(sizeof(unsigned short)*w*h))) {
1068 fprintf(stderr,"fx Driver: out of memory !\n");
1069 fxCloseHardware();
1070 exit(-1);
1071 }
1072 } else
1073 src=(*dest);
1074
1075 if(wscale==hscale==1) {
1076 int i=0;
1077 int lenght=h*w;
1078 unsigned r,g,b,a;
1079
1080 while(i++<lenght) {
1081 r=*data++;
1082 g=*data++;
1083 b=*data++;
1084 a=*data++;
1085 *src++=((0x80 & a) << 8) |
1086 ((0xf8 & r) << 7) |
1087 ((0xf8 & g) << 2) |
1088 ((0xf8 & b) >> 3);
1089 }
1090 } else {
1091 unsigned r,g,b,a;
1092
1093 for(y=0;y<h;y++)
1094 for(x=0;x<w;x++) {
1095 idx=(x/wscale+(y/hscale)*(w/wscale))*4;
1096 r=data[idx];
1097 g=data[idx+1];
1098 b=data[idx+2];
1099 a=data[idx+3];
1100
1101 src[x+y*w]=((0x80 & a) << 8) |
1102 ((0xf8 & r) << 7) |
1103 ((0xf8 & g) << 2) |
1104 ((0xf8 & b) >> 3);
1105 }
1106 }
1107 break;
1108 default:
1109 fprintf(stderr,"fx Driver: wrong internalFormat in texbuildimagemap()\n");
1110 fxCloseHardware();
1111 EXIT(-1);
1112 break;
1113 }
1114}
1115
1116void fxDDTexImg(GLcontext *ctx, GLenum target,
1117 struct gl_texture_object *tObj, GLint level, GLint internalFormat,
1118 const struct gl_texture_image *image)
1119{
1120 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
1121 tfxTexInfo *ti;
1122
1123 if (MESA_VERBOSE&VERBOSE_DRIVER) {
1124 fprintf(stderr,
1125 "fxmesa: (%d) fxDDTexImg(...,level=%d,target=%d,format=%x,width=%d,height=%d...)\n",
1126 tObj->Name, level, target, internalFormat, image->Width,
1127 image->Height);
1128 }
1129
1130 if(target!=GL_TEXTURE_2D)
1131 return;
1132
1133 if (!tObj->DriverData)
1134 tObj->DriverData=fxAllocTexObjData(fxMesa);
1135
1136 ti=fxTMGetTexInfo(tObj);
1137
1138 if(fxIsTexSupported(target,internalFormat,image)) {
1139 GrTextureFormat_t gldformat;
1140 tfxMipMapLevel *mml=&ti->mipmapLevel[level];
1141
1142 fxTexGetFormat((GLenum)internalFormat,&gldformat,NULL);
1143
1144 if(mml->used) {
1145 if((mml->glideFormat==gldformat) &&
1146 (mml->width==image->Width) &&
1147 (mml->height==image->Height)) {
1148 fxTexBuildImageMap(image,internalFormat,&(mml->data),
1149 &(mml->translated));
1150
1151 if(ti->validated && ti->isInTM)
1152 fxTMReloadMipMapLevel(fxMesa,tObj,level);
1153 else
1154 fxTexInvalidate(ctx,tObj);
1155
1156 return;
1157 } else {
1158 if(mml->translated)
1159 FREE(mml->data);
1160 mml->data=NULL;
1161 }
1162 }
1163
1164 mml->glideFormat=gldformat;
1165 mml->width=image->Width;
1166 mml->height=image->Height;
1167 mml->used=GL_TRUE;
1168
1169 fxTexBuildImageMap(image,internalFormat,&(mml->data),
1170 &(mml->translated));
1171
1172 fxTexInvalidate(ctx,tObj);
1173 }
1174#ifndef FX_SILENT
1175 else
1176 fprintf(stderr,"fx Driver: unsupported texture in fxDDTexImg()\n");
1177#endif
1178}
1179
1180static void fxTexBuildSubImageMap(const struct gl_texture_image *image,
1181 GLint internalFormat,
1182 GLint xoffset, GLint yoffset, GLint width, GLint height,
1183 unsigned short *destimg)
1184{
1185 fxTexGetInfo(image->Width,image->Height,NULL,NULL,NULL,NULL,NULL,NULL,
1186 NULL,NULL);
1187
1188 switch(internalFormat) {
1189 case GL_INTENSITY:
1190 case GL_INTENSITY4:
1191 case GL_INTENSITY8:
1192 case GL_INTENSITY12:
1193 case GL_INTENSITY16:
1194 case 1:
1195 case GL_LUMINANCE:
1196 case GL_LUMINANCE4:
1197 case GL_LUMINANCE8:
1198 case GL_LUMINANCE12:
1199 case GL_LUMINANCE16:
1200 case GL_ALPHA:
1201 case GL_ALPHA4:
1202 case GL_ALPHA8:
1203 case GL_ALPHA12:
1204 case GL_ALPHA16:
1205 case GL_COLOR_INDEX:
1206 case GL_COLOR_INDEX1_EXT:
1207 case GL_COLOR_INDEX2_EXT:
1208 case GL_COLOR_INDEX4_EXT:
1209 case GL_COLOR_INDEX8_EXT:
1210 case GL_COLOR_INDEX12_EXT:
1211 case GL_COLOR_INDEX16_EXT:
1212 {
1213
1214 int y;
1215 unsigned char *bsrc,*bdst;
1216
1217 bsrc=(unsigned char *)(image->Data+(yoffset*image->Width+xoffset));
1218 bdst=((unsigned char *)destimg)+(yoffset*image->Width+xoffset);
1219
1220 for(y=0;y<height;y++) {
1221 MEMCPY(bdst,bsrc,width);
1222 bsrc += image->Width;
1223 bdst += image->Width;
1224 }
1225 }
1226 break;
1227 case 2:
1228 case GL_LUMINANCE_ALPHA:
1229 case GL_LUMINANCE4_ALPHA4:
1230 case GL_LUMINANCE6_ALPHA2:
1231 case GL_LUMINANCE8_ALPHA8:
1232 case GL_LUMINANCE12_ALPHA4:
1233 case GL_LUMINANCE12_ALPHA12:
1234 case GL_LUMINANCE16_ALPHA16:
1235 {
1236 int x,y;
1237 unsigned char *src;
1238 unsigned short *dst,a,l;
1239 int simgw,dimgw;
1240
1241 src=(unsigned char *)(image->Data+(yoffset*image->Width+xoffset)*2);
1242 dst=destimg+(yoffset*image->Width+xoffset);
1243
1244 simgw=(image->Width-width)*2;
1245 dimgw=image->Width-width;
1246 for(y=0;y<height;y++) {
1247 for(x=0;x<width;x++) {
1248 l=*src++;
1249 a=*src++;
1250 *dst++=(a << 8) | l;
1251 }
1252
1253 src += simgw;
1254 dst += dimgw;
1255 }
1256 }
1257 break;
1258 case 3:
1259 case GL_RGB:
1260 case GL_R3_G3_B2:
1261 case GL_RGB4:
1262 case GL_RGB5:
1263 case GL_RGB8:
1264 case GL_RGB10:
1265 case GL_RGB12:
1266 case GL_RGB16:
1267 {
1268 int x,y;
1269 unsigned char *src;
1270 unsigned short *dst,r,g,b;
1271 int simgw,dimgw;
1272
1273 src=(unsigned char *)(image->Data+(yoffset*image->Width+xoffset)*3);
1274 dst=destimg+(yoffset*image->Width+xoffset);
1275
1276 simgw=(image->Width-width)*3;
1277 dimgw=image->Width-width;
1278 for(y=0;y<height;y++) {
1279 for(x=0;x<width;x++) {
1280 r=*src++;
1281 g=*src++;
1282 b=*src++;
1283 *dst++=((0xf8 & r) << (11-3)) |
1284 ((0xfc & g) << (5-3+1)) |
1285 ((0xf8 & b) >> 3);
1286 }
1287
1288 src += simgw;
1289 dst += dimgw;
1290 }
1291 }
1292 break;
1293 case 4:
1294 case GL_RGBA:
1295 case GL_RGBA2:
1296 case GL_RGBA4:
1297 case GL_RGBA8:
1298 case GL_RGB10_A2:
1299 case GL_RGBA12:
1300 case GL_RGBA16:
1301 {
1302 int x,y;
1303 unsigned char *src;
1304 unsigned short *dst,r,g,b,a;
1305 int simgw,dimgw;
1306
1307 src=(unsigned char *)(image->Data+(yoffset*image->Width+xoffset)*4);
1308 dst=destimg+(yoffset*image->Width+xoffset);
1309
1310 simgw=(image->Width-width)*4;
1311 dimgw=image->Width-width;
1312 for(y=0;y<height;y++) {
1313 for(x=0;x<width;x++) {
1314 r=*src++;
1315 g=*src++;
1316 b=*src++;
1317 a=*src++;
1318 *dst++=((0xf0 & a) << 8) |
1319 ((0xf0 & r) << 4) |
1320 (0xf0 & g) |
1321 ((0xf0 & b) >> 4);
1322 }
1323
1324 src += simgw;
1325 dst += dimgw;
1326 }
1327 }
1328 break;
1329 case GL_RGB5_A1:
1330 {
1331 int x,y;
1332 unsigned char *src;
1333 unsigned short *dst,r,g,b,a;
1334 int simgw,dimgw;
1335
1336 src=(unsigned char *)(image->Data+(yoffset*image->Width+xoffset)*4);
1337 dst=destimg+(yoffset*image->Width+xoffset);
1338
1339 simgw=(image->Width-width)*4;
1340 dimgw=image->Width-width;
1341 for(y=0;y<height;y++) {
1342 for(x=0;x<width;x++) {
1343 r=*src++;
1344 g=*src++;
1345 b=*src++;
1346 a=*src++;
1347 *dst++=
1348 ((0x80 & a) << 8) |
1349 ((0xf8 & r) << 7) |
1350 ((0xf8 & g) << 2) |
1351 ((0xf8 & b) >> 3);
1352 }
1353
1354 src += simgw;
1355 dst += dimgw;
1356 }
1357 }
1358 break;
1359 default:
1360 fprintf(stderr,"fx Driver: wrong internalFormat in fxTexBuildSubImageMap()\n");
1361 fxCloseHardware();
1362 EXIT(-1);
1363 break;
1364 }
1365}
1366
1367
1368void fxDDTexSubImg(GLcontext *ctx, GLenum target,
1369 struct gl_texture_object *tObj, GLint level,
1370 GLint xoffset, GLint yoffset, GLint width, GLint height,
1371 GLint internalFormat, const struct gl_texture_image *image)
1372{
1373 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
1374 tfxTexInfo *ti;
1375 GrTextureFormat_t gldformat;
1376 int wscale,hscale;
1377 tfxMipMapLevel *mml;
1378
1379 if (MESA_VERBOSE&VERBOSE_DRIVER) {
1380 fprintf(stderr,
1381 "fxmesa: (%d) fxDDTexSubImg(level=%d,target=%d,format=%x,width=%d,height=%d)\n",
1382 tObj->Name, level, target, internalFormat, image->Width,
1383 image->Height);
1384 }
1385
1386 if(target!=GL_TEXTURE_2D)
1387 return;
1388
1389 if (!tObj->DriverData)
1390 return;
1391
1392 ti=fxTMGetTexInfo(tObj);
1393 mml=&ti->mipmapLevel[level];
1394
1395 fxTexGetFormat((GLenum)internalFormat,&gldformat,NULL);
1396
1397 if(mml->glideFormat!=gldformat) {
1398 if (MESA_VERBOSE&VERBOSE_DRIVER) {
1399 fprintf(stderr,"fxmesa: ti->info.format!=format in fxDDTexSubImg()\n");
1400 }
1401 fxDDTexImg(ctx,target,tObj,level,internalFormat,image);
1402
1403 return;
1404 }
1405
1406 fxTexGetInfo(image->Width,image->Height,NULL,NULL,NULL,NULL,NULL,NULL,&wscale,&hscale);
1407
1408 if((wscale!=1) || (hscale!=1)) {
1409 if (MESA_VERBOSE&VERBOSE_DRIVER) {
1410 fprintf(stderr,"fxmesa: (wscale!=1) || (hscale!=1) in fxDDTexSubImg()\n");
1411 }
1412 fxDDTexImg(ctx,target,tObj,level,internalFormat,image);
1413
1414 return;
1415 }
1416
1417 if(mml->translated)
1418 fxTexBuildSubImageMap(image,internalFormat,xoffset,yoffset,
1419 width,height,mml->data);
1420
1421 if(ti->validated && ti->isInTM)
1422 fxTMReloadSubMipMapLevel(fxMesa,tObj,level,yoffset,height);
1423 else
1424 fxTexInvalidate(ctx,tObj);
1425}
1426
1427
1428
1429/**********************************************************************/
1430/**** NEW TEXTURE IMAGE FUNCTIONS ****/
1431/**********************************************************************/
1432
1433GLboolean fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
1434 GLenum format, GLenum type, const GLvoid *pixels,
1435 const struct gl_pixelstore_attrib *packing,
1436 struct gl_texture_object *texObj,
1437 struct gl_texture_image *texImage,
1438 GLboolean *retainInternalCopy)
1439{
1440 *retainInternalCopy = GL_TRUE;
1441 return GL_FALSE;
1442}
1443
1444
1445GLboolean fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
1446 GLint xoffset, GLint yoffset,
1447 GLsizei width, GLsizei height,
1448 GLenum format, GLenum type, const GLvoid *pixels,
1449 const struct gl_pixelstore_attrib *packing,
1450 struct gl_texture_object *texObj,
1451 struct gl_texture_image *texImage)
1452{
1453
1454 return GL_FALSE;
1455}
1456
1457
1458#else
1459
1460
1461/*
1462 * Need this to provide at least one external definition.
1463 */
1464
1465int gl_fx_dummy_function_ddtex(void)
1466{
1467 return 0;
1468}
1469
1470#endif /* FX */
Note: See TracBrowser for help on using the repository browser.