DXGL r909 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r908‎ | r909 | r910 >
Date:22:28, 6 April 2019
Author:admin
Status:new
Tags:
Comment:
Store luminance-only formats as red-only unless defined as textures.
Modified paths:
  • /ddraw/ShaderGen2D.cpp (modified) (history)
  • /ddraw/glTexture.cpp (modified) (history)

Diff [purge]

Index: ddraw/ShaderGen2D.cpp
@@ -61,7 +61,7 @@
6262
6363 Texture types:
6464 0x00: Classic DXGL processing
65 -0x01: 32-bit YUV444, 8-bit component (convert from other formats via software)
 65+0x01: Luminance-only (write to red)
6666 0x10: 8-bit palette
6767 0x11: 4-bit palette
6868 0x12: 2-bit palette
@@ -140,6 +140,7 @@
141141 vec2 index = vec2(((myindex.x*(255.0/256.0))+(0.5/256.0)),0.5);\n\
142142 pixel = ivec4(texture2D(srcpal, index)*vec4(colorsizedest)+.5);\n";
143143 static const char op_pixelmul256[] = "pixel = ivec4(vec4(256.0)*texture2D(srctex,gl_TexCoord[0].st)*vec4(colorsizedest)+.5);\n";
 144+static const char op_lumpixel[] = "pixel = ivec4(vec4(texture2D(srctex,gl_TexCoord[0].st).rrr,1.0)*vec4(colorsizedest)+.5);\n";
144145 static const char op_color[] = "pixel = fillcolor;\n";
145146 static const char op_dest[] = "dest = ivec4(texture2D(desttex,gl_TexCoord[1].st)*vec4(colorsizedest)+.5);\n";
146147 static const char op_pattern[] = "patternst = vec2(mod(gl_FragCoord.x,float(patternsize.x))/float(patternsize.x),\n\
@@ -953,10 +954,13 @@
954955 {
955956 switch (srctype2)
956957 {
957 - case 0:
 958+ case 0x00:
958959 default:
959960 String_Append(fsrc, op_pixel);
960961 break;
 962+ case 0x01:
 963+ String_Append(fsrc, op_lumpixel);
 964+ break;
961965 case 0x10:
962966 case 0x11:
963967 case 0x12:
Index: ddraw/glTexture.cpp
@@ -1196,14 +1196,23 @@
11971197 This->colorbits[3] = 8;
11981198 This->packsize = 1;
11991199 break;
1200 - case DXGLPIXELFORMAT_LUM8: // 8-bit Luminance
1201 - case DXGLPIXELFORMAT_FOURCC_Y8:
 1200+ case DXGLPIXELFORMAT_FOURCC_Y8: // 8-bit Y-only
12021201 case DXGLPIXELFORMAT_FOURCC_Y800:
12031202 case DXGLPIXELFORMAT_FOURCC_GREY:
1204 - This->internalformats[0] = GL_LUMINANCE8;
 1203+ case DXGLPIXELFORMAT_LUM8: // 8-bit Luminance
 1204+ This->blttype = 0x01;
 1205+ if (This->renderer->ext->glver_major >= 3 && !(This->levels[0].ddsd.ddsCaps.dwCaps & DDSCAPS_TEXTURE))
 1206+ {
 1207+ This->internalformats[0] = GL_R8;
 1208+ This->format = GL_RED;
 1209+ }
 1210+ else
 1211+ {
 1212+ This->internalformats[0] = GL_LUMINANCE8;
 1213+ This->format = GL_LUMINANCE;
 1214+ }
12051215 This->internalformats[1] = GL_RGB8;
12061216 This->internalformats[2] = GL_RGBA8;
1207 - This->format = GL_LUMINANCE;
12081217 This->type = GL_UNSIGNED_BYTE;
12091218 if (!This->target) This->target = GL_TEXTURE_2D;
12101219 This->colororder = 5;
@@ -1370,8 +1379,17 @@
13711380 This->packsize = 1;
13721381 break;
13731382 case DXGLPIXELFORMAT_FOURCC_Y16:
1374 - This->internalformats[0] = GL_LUMINANCE16;
1375 - This->format = GL_LUMINANCE;
 1383+ This->blttype = 0x01;
 1384+ if (This->renderer->ext->glver_major >= 3 && !(This->levels[0].ddsd.ddsCaps.dwCaps & DDSCAPS_TEXTURE))
 1385+ {
 1386+ This->internalformats[0] = GL_R16;
 1387+ This->format = GL_RED;
 1388+ }
 1389+ else
 1390+ {
 1391+ This->internalformats[0] = GL_LUMINANCE16;
 1392+ This->format = GL_LUMINANCE;
 1393+ }
13761394 This->type = GL_UNSIGNED_SHORT;
13771395 if (!This->target) This->target = GL_TEXTURE_2D;
13781396 This->colororder = 4;