Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/d3d9/tests/visual.c | 395 ++++++++++++++++++++++----------------- 1 file changed, 227 insertions(+), 168 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 6b3466ece5..31b05f7501 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -3767,26 +3767,49 @@ done:
static void fill_surface(IDirect3DSurface9 *surface, DWORD color, DWORD flags) { + unsigned int byte_count; D3DSURFACE_DESC desc; + unsigned int x, y; D3DLOCKED_RECT l; HRESULT hr; - unsigned int x, y; - DWORD *mem; + void *mem;
memset(&desc, 0, sizeof(desc)); memset(&l, 0, sizeof(l)); hr = IDirect3DSurface9_GetDesc(surface, &desc); ok(hr == D3D_OK, "IDirect3DSurface9_GetDesc failed with %08x\n", hr); + + switch(desc.Format) + { + case D3DFMT_A8R8G8B8: + case D3DFMT_X8R8G8B8: + byte_count = 4; + break; + + case D3DFMT_A1R5G5B5: + case D3DFMT_X1R5G5B5: + case D3DFMT_R5G6B5: + byte_count = 2; + break; + + default: + ok(0, "Unsupported format %#x.\n", desc.Format); + return; + } + hr = IDirect3DSurface9_LockRect(surface, &l, NULL, flags); ok(hr == D3D_OK, "IDirect3DSurface9_LockRect failed with %08x\n", hr); if(FAILED(hr)) return;
for(y = 0; y < desc.Height; y++) { - mem = (DWORD *) ((BYTE *) l.pBits + y * l.Pitch); - for(x = 0; x < l.Pitch / sizeof(DWORD); x++) + mem = (BYTE *)l.pBits + y * l.Pitch; + for(x = 0; x < l.Pitch / byte_count; ++x) { - mem[x] = color; + if (byte_count == 4) + ((DWORD *)mem)[x] = color; + else + ((WORD *)mem)[x] = color; } } hr = IDirect3DSurface9_UnlockRect(surface); @@ -8964,7 +8987,8 @@ static void srgbtexture_test(void) struct IDirect3DSurface9 *surface; IDirect3DDevice9 *device; IDirect3D9 *d3d; - D3DCOLOR color; + D3DCOLOR colour; + unsigned int i; ULONG refcount; HWND window; DWORD value; @@ -8977,6 +9001,25 @@ static void srgbtexture_test(void) 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, }; + static const struct + { + D3DFORMAT format; + const char *format_name; + DWORD fill_colour1, fill_colour2; + DWORD fill_colour_rb1, fill_colour_rb2; + DWORD conv_colour1, conv_colour2; + } + tests[] = + { + {D3DFMT_A8R8G8B8, "A8R8G8B8", + 0xff7f7f7f, 0xff3f3f3f, 0x007f7f7f, 0x003f3f3f, 0x00363636, 0x000d0d0d}, + {D3DFMT_R5G6B5, "R5G6R5", + 0x7bef, 0x39e7, 0x007b7d7b, 0x003a3d3a, 0x00333433, 0x000a0c0a}, + {D3DFMT_A1R5G5B5, "A1R5G5R5", + 0xbdef, 0x9ce7, 0x007b7b7b, 0x003a3a3a, 0x00333433, 0x000a0a0a}, + {D3DFMT_X1R5G5B5, "X1R5G5R5", + 0x3def, 0x1ce7, 0x007b7b7b, 0x003a3a3a, 0x00333433, 0x000a0a0a}, + };
window = create_window(); d3d = Direct3DCreate9(D3D_SDK_VERSION); @@ -8987,179 +9030,195 @@ static void srgbtexture_test(void) goto done; }
- if (IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, - D3DFMT_X8R8G8B8, D3DUSAGE_QUERY_SRGBREAD, D3DRTYPE_TEXTURE, D3DFMT_A8R8G8B8) != D3D_OK) + for (i = 0; i < ARRAY_SIZE(tests); ++i) { - skip("D3DFMT_A8R8G8B8 textures with SRGBREAD not supported.\n"); - IDirect3DDevice9_Release(device); - goto done; - } + if (IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, + D3DFMT_X8R8G8B8, D3DUSAGE_QUERY_SRGBREAD, D3DRTYPE_TEXTURE, tests[i].format) != D3D_OK) + { + skip("%s textures with SRGBREAD are not supported.\n", tests[i].format_name); + continue; + }
- hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 2, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &texture, NULL); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - fill_surface(surface, 0xff7f7f7f, 0); - IDirect3DSurface9_Release(surface); - hr = IDirect3DTexture9_GetSurfaceLevel(texture, 1, &surface); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - fill_surface(surface, 0xff3f3f3f, 0); - IDirect3DSurface9_Release(surface); + hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 2, 0, tests[i].format, D3DPOOL_MANAGED, &texture, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DTexture9_GetSurfaceLevel(texture, 0, &surface); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + fill_surface(surface, tests[i].fill_colour1, 0); + IDirect3DSurface9_Release(surface); + hr = IDirect3DTexture9_GetSurfaceLevel(texture, 1, &surface); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + fill_surface(surface, tests[i].fill_colour2, 0); + IDirect3DSurface9_Release(surface);
- hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *)texture); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- /* AMD uses the LSB of the D3DSAMP_SRGBTEXTURE value. - * NVIDIA ignores any values other than 0 and 1, leaving the previous - * D3DSAMP_SRGBTEXTURE state. - * Intel, WARP treat the value as boolean. */ - hr = IDirect3DDevice9_BeginScene(device); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 0x7e41882a); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - ok(value == 0x7e41882a, "Got unexpected value %#x.\n", value); - hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float)); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_EndScene(device); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - color = getPixelColor(device, 320, 240); - ok(color_match(color, 0x007f7f7f, 1) || broken(color_match(color, 0x00363636, 1)), - "Got unexpected color 0x%08x.\n", color); - hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + /* AMD uses the LSB of the D3DSAMP_SRGBTEXTURE value. + * NVIDIA ignores any values other than 0 and 1, leaving the previous + * D3DSAMP_SRGBTEXTURE state. + * Intel, WARP treat the value as boolean. */ + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 0x7e41882a); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(value == 0x7e41882a, "Got unexpected value %#x.\n", value); + hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float)); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + colour = getPixelColor(device, 320, 240); + ok(color_match(colour, tests[i].fill_colour_rb1, 1) + || broken(color_match(colour, tests[i].conv_colour1, 1)), + "Format %s, got unexpected colour 0x%08x.\n", tests[i].format_name, colour); + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- hr = IDirect3DDevice9_BeginScene(device); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 100); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - ok(value == 100, "Got unexpected value %#x.\n", value); - hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float)); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_EndScene(device); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - color = getPixelColor(device, 320, 240); - ok(color_match(color, 0x007f7f7f, 1) || broken(color_match(color, 0x00363636, 1)), - "Got unexpected color 0x%08x.\n", color); - hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 100); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(value == 100, "Got unexpected value %#x.\n", value); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float)); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + colour = getPixelColor(device, 320, 240); + ok(color_match(colour, tests[i].fill_colour_rb1, 1) + || broken(color_match(colour, tests[i].conv_colour1, 1)), + "Format %s, got unexpected colour 0x%08x.\n", tests[i].format_name, colour); + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- hr = IDirect3DDevice9_BeginScene(device); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 2); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - ok(value == 2, "Got unexpected value %#x.\n", value); - hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float)); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_EndScene(device); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - color = getPixelColor(device, 320, 240); - ok(color_match(color, 0x007f7f7f, 1) || broken(color_match(color, 0x00363636, 1)), - "Got unexpected color 0x%08x.\n", color); - hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 2); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(value == 2, "Got unexpected value %#x.\n", value); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float)); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + colour = getPixelColor(device, 320, 240); + ok(color_match(colour, tests[i].fill_colour_rb1, 1) + || broken(color_match(colour, tests[i].conv_colour1, 1)), + "Format %s, got unexpected colour 0x%08x.\n", tests[i].format_name, colour); + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- hr = IDirect3DDevice9_BeginScene(device); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 3); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - ok(value == 3, "Got unexpected value %#x.\n", value); - hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float)); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_EndScene(device); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - color = getPixelColor(device, 320, 240); - ok(color_match(color, 0x007f7f7f, 1) || color_match(color, 0x00363636, 1), - "Got unexpected color 0x%08x.\n", color); - hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 3); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(value == 3, "Got unexpected value %#x.\n", value); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float)); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + colour = getPixelColor(device, 320, 240); + ok(color_match(colour, tests[i].fill_colour_rb1, 1) + || color_match(colour, tests[i].conv_colour1, 1), + "Format %s, got unexpected colour 0x%08x.\n", tests[i].format_name, colour); + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- hr = IDirect3DDevice9_BeginScene(device); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, TRUE); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - ok(value == TRUE, "Got unexpected value %#x.\n", value); - hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float)); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_EndScene(device); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - color = getPixelColor(device, 320, 240); - ok(color_match(color, 0x00363636, 1), "Got unexpected color 0x%08x.\n", color); - hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, TRUE); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(value == TRUE, "Got unexpected value %#x.\n", value); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float)); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + colour = getPixelColor(device, 320, 240); + ok(color_match(colour, tests[i].conv_colour1, 1), "Format %s, got unexpected colour 0x%08x.\n", + tests[i].format_name, colour); + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- hr = IDirect3DDevice9_BeginScene(device); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - /* Set the other state to verify that the sampler just inherits old - * D3DSAMP_SRGBTEXTURE but * the old sampler is not preserved entirely on - * NVIDIA. */ - hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 0x7e41882a); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - ok(value == 0x7e41882a, "Got unexpected value %#x.\n", value); - hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 1); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float)); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_EndScene(device); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - color = getPixelColor(device, 320, 240); - ok(color_match(color, 0x000d0d0d, 1) || color_match(color, 0x003f3f3f, 1), - "Got unexpected color 0x%08x.\n", color); - hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + /* Set the other state to verify that the sampler just inherits old + * D3DSAMP_SRGBTEXTURE but the old sampler is not preserved entirely on + * NVIDIA. */ + hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 0x7e41882a); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(value == 0x7e41882a, "Got unexpected value %#x.\n", value); + hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MIPFILTER, D3DTEXF_POINT); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float)); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + colour = getPixelColor(device, 320, 240); + ok(color_match(colour, tests[i].conv_colour2, 1) + || color_match(colour, tests[i].fill_colour_rb2, 1), + "Format %s, got unexpected colour 0x%08x.\n", tests[i].format_name, colour); + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
- hr = IDirect3DDevice9_BeginScene(device); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 0); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - ok(value == 0, "Got unexpected value %#x.\n", value); - hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float)); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_EndScene(device); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - color = getPixelColor(device, 320, 240); - ok(color_match(color, 0x003f3f3f, 1), "Got unexpected color 0x%08x.\n", color); - hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(value == 0, "Got unexpected value %#x.\n", value); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float)); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + colour = getPixelColor(device, 320, 240); + ok(color_match(colour, tests[i].fill_colour_rb2, 1), + "Format %s, got unexpected colour 0x%08x.\n", tests[i].format_name, colour); + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 0x7e41882a); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(value == 0x7e41882a, "Got unexpected value %#x.\n", value); + hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float)); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + colour = getPixelColor(device, 320, 240); + ok(color_match(colour, tests[i].fill_colour_rb2, 1) + || broken(color_match(colour, tests[i].conv_colour2, 1)), + "Format %s, got unexpected colour 0x%08x.\n", tests[i].format_name, colour); + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + IDirect3DTexture9_Release(texture); + + hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAXMIPLEVEL, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + }
- hr = IDirect3DDevice9_BeginScene(device); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, 0x7e41882a); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_GetSamplerState(device, 0, D3DSAMP_SRGBTEXTURE, &value); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - ok(value == 0x7e41882a, "Got unexpected value %#x.\n", value); - hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float)); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - hr = IDirect3DDevice9_EndScene(device); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - color = getPixelColor(device, 320, 240); - ok(color_match(color, 0x003f3f3f, 1) || broken(color_match(color, 0x000d0d0d, 1)), - "Got unexpected color 0x%08x.\n", color); - hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); - ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - IDirect3DTexture9_Release(texture); refcount = IDirect3DDevice9_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); done:
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48302 Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/wined3d/utils.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 6ea1bb95f9..c8a2c6633c 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -1532,15 +1532,15 @@ static const struct wined3d_format_texture_info format_texture_info[] = WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE, WINED3D_GL_EXT_NONE, NULL}, - {WINED3DFMT_B5G6R5_UNORM, GL_RGB5, GL_RGB5, GL_RGB8, + {WINED3DFMT_B5G6R5_UNORM, GL_RGB5, GL_SRGB8_EXT, GL_RGB8, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 0, WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING - | WINED3DFMT_FLAG_RENDERTARGET, + | WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_SRGB_READ, WINED3D_GL_EXT_NONE, NULL}, - {WINED3DFMT_B5G6R5_UNORM, GL_RGB565, GL_RGB565, GL_RGB8, + {WINED3DFMT_B5G6R5_UNORM, GL_RGB565, GL_SRGB8_EXT, GL_RGB8, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 0, WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING - | WINED3DFMT_FLAG_RENDERTARGET, + | WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_SRGB_READ, ARB_ES2_COMPATIBILITY, NULL}, {WINED3DFMT_B5G5R5X1_UNORM, GL_RGB5, GL_RGB5, 0, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 0,
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/wined3d/utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index c8a2c6633c..4d47aced94 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -1542,10 +1542,10 @@ static const struct wined3d_format_texture_info format_texture_info[] = WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_SRGB_READ, ARB_ES2_COMPATIBILITY, NULL}, - {WINED3DFMT_B5G5R5X1_UNORM, GL_RGB5, GL_RGB5, 0, + {WINED3DFMT_B5G5R5X1_UNORM, GL_RGB5, GL_SRGB8_EXT, 0, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 0, WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING - | WINED3DFMT_FLAG_RENDERTARGET, + | WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_SRGB_READ, WINED3D_GL_EXT_NONE, NULL}, {WINED3DFMT_B5G5R5A1_UNORM, GL_RGB5_A1, GL_RGB5_A1, 0, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 0,
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/wined3d/utils.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 4d47aced94..60408b0fc2 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -1547,9 +1547,10 @@ static const struct wined3d_format_texture_info format_texture_info[] = WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET | WINED3DFMT_FLAG_SRGB_READ, WINED3D_GL_EXT_NONE, NULL}, - {WINED3DFMT_B5G5R5A1_UNORM, GL_RGB5_A1, GL_RGB5_A1, 0, + {WINED3DFMT_B5G5R5A1_UNORM, GL_RGB5_A1, GL_SRGB8_ALPHA8_EXT, 0, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 0, - WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, + WINED3DFMT_FLAG_TEXTURE | WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING + | WINED3DFMT_FLAG_SRGB_READ, WINED3D_GL_EXT_NONE, NULL}, {WINED3DFMT_B4G4R4A4_UNORM, GL_RGBA4, GL_SRGB8_ALPHA8_EXT, 0, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 0,
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
On Mon, 13 Jan 2020 at 19:02, Paul Gofman gofmanp@gmail.com wrote:
case D3DFMT_A1R5G5B5:
case D3DFMT_X1R5G5B5:
case D3DFMT_R5G6B5:
Are these generally supported on NVIDIA? They don't appear to be supported on my AMD system. That's not necessarily an issue, but does raise the question whether applications can really depend on these formats supporting sRGB reads.
All of them are supported on Nvidia GeForce GT 650M where I tested that on Windows. All but _X1R5G5B5 are also supported on Intel. If _R5G6B5 is not supported on AMD then probably Warhammer takes some other path on AMD. I don't have an AMD to test that but I can try spoofing AMD in Wine registry keys to see if it makes any difference. In case it does, it might be possible to find out how it works on AMD.
On 1/21/20 16:27, Henri Verbeet wrote:
On Mon, 13 Jan 2020 at 19:02, Paul Gofman gofmanp@gmail.com wrote:
case D3DFMT_A1R5G5B5:
case D3DFMT_X1R5G5B5:
case D3DFMT_R5G6B5:
Are these generally supported on NVIDIA? They don't appear to be supported on my AMD system. That's not necessarily an issue, but does raise the question whether applications can really depend on these formats supporting sRGB reads.
I've tested the game with AMD graphics card override under Wine (VideoPciVendorID 0x1002, VideoPciDeviceId 0x67df) and it seems to fix the rendering on its own. So the game expects _R5G6B5 to have SRGB reads supported only if detects the GPU as Nvidia (at least), otherwise it works some other way. Yet I suppose adding the SRGB read support as on Nvidia might be a valid fix unless we want to make the support depend on the reported video card.
On 1/21/20 16:53, Paul Gofman wrote:
All of them are supported on Nvidia GeForce GT 650M where I tested that on Windows. All but _X1R5G5B5 are also supported on Intel. If _R5G6B5 is not supported on AMD then probably Warhammer takes some other path on AMD. I don't have an AMD to test that but I can try spoofing AMD in Wine registry keys to see if it makes any difference. In case it does, it might be possible to find out how it works on AMD.
On 1/21/20 16:27, Henri Verbeet wrote:
On Mon, 13 Jan 2020 at 19:02, Paul Gofman gofmanp@gmail.com wrote:
case D3DFMT_A1R5G5B5:
case D3DFMT_X1R5G5B5:
case D3DFMT_R5G6B5:
Are these generally supported on NVIDIA? They don't appear to be supported on my AMD system. That's not necessarily an issue, but does raise the question whether applications can really depend on these formats supporting sRGB reads.
On Tue, 21 Jan 2020 at 18:46, Paul Gofman gofmanp@gmail.com wrote:
I've tested the game with AMD graphics card override under Wine (VideoPciVendorID 0x1002, VideoPciDeviceId 0x67df) and it seems to fix the rendering on its own. So the game expects _R5G6B5 to have SRGB reads supported only if detects the GPU as Nvidia (at least), otherwise it works some other way. Yet I suppose adding the SRGB read support as on Nvidia might be a valid fix unless we want to make the support depend on the reported video card.
It's a little unfortunate to use GL_SRGB8 for R5G6B5 because it implies conversions on uploads and downloads, as well as doubling GPU memory usage for the affected formats. I don't think that's necessarily prohibitive, but if there's a reasonable way to avoid supporting sRGB reads on these formats, I think that would be preferred.
But isn't that just for the cases when SRGB is actually used on these formats, which appears to be quite a rare case? If that's still a problem maybe we can advertise SRGB reads for Nvidia only? Frankly I don't yet see any other way to fix that without some game specific workarounds. And for that particular game only _R5G6B5 is required, I don't have any real examples for the other formats the patches concern.
On 1/21/20 19:27, Henri Verbeet wrote:
It's a little unfortunate to use GL_SRGB8 for R5G6B5 because it implies conversions on uploads and downloads, as well as doubling GPU memory usage for the affected formats. I don't think that's necessarily prohibitive, but if there's a reasonable way to avoid supporting sRGB reads on these formats, I think that would be preferred.
On Tue, 21 Jan 2020 at 20:12, Paul Gofman gofmanp@gmail.com wrote:
But isn't that just for the cases when SRGB is actually used on these formats, which appears to be quite a rare case?
Not for d3d9 + EXT_texture_sRGB_decode, no. In that case textures supporting sRGB reads are created with the sRGB format, and sRGB read conversion is disabled unless the appropriate sampler state is enabled.
On 1/21/20 19:52, Henri Verbeet wrote:
Not for d3d9 + EXT_texture_sRGB_decode, no. In that case textures supporting sRGB reads are created with the sRGB format, and sRGB read conversion is disabled unless the appropriate sampler state is enabled.
I additionally verified that the game works the same way on Windows with Nvidia by recording apitrace. So it works the same way under Wine and there are very little chances that we can make it to avoid this format in some sensible way on Nvidia other than faking AMD card through registry.
It looks to me when the texture storage is allocated in wined3d_texture_gl_prepare_texture() format_gl->srgb_internal is used only if wined3d_texture_gl_prepare_texture() is called with srgb parameter set to TRUE, which happens only if texture loaded to SRGB location, which happens only if texture is being bound as SRGB, which should happen only if SRGB is enabled for sampler (sampler() state in state.c controls that). If I did not miss something important here, the unfortunate _SRGB8 GL format may only affect things for d3d9 if application is actually trying to use 16 bit format as SRGB. It might not be true for binding shader resources for d3d10+, but in this case maybe we can fix up WINED3DFMT_FLAG_SRGB_READ for 16 bit formats based on WINED3D_SRGB_READ_WRITE_CONTROL wined3d creation flag?
The other way it should be possible to introduce an option for some d3d formats to perform SRGB read without using GL SRGB internal format by explicit conversion in GLSL shader. This would add a GL shader setting and require appropriate changes through format table building and SRGB flag handing.
Am 21.01.20 um 21:17 schrieb Paul Gofman:
If I did not miss something important here, the unfortunate _SRGB8 GL format may only affect things for d3d9 if application is actually trying to use 16 bit format as SRGB
utils.c, check_fbo_compat() and the internalformat_query2 equivalents:
if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE]) format->internal = format->srgb_internal;
That's because EXT_texture_sRGB_decode can only switch sRGB off for sRGB textures, it can't switch it on for RGB textures. So we create all as sRGB and switch it off until the app enables it.
We have a fallback codepath in case EXT_TEXTURE_SRGB_DECODE is not available. We'd have to enable this fallback codepath for 16 bit formats, otherwise all 16 bit RGB textures will have the 32 bit conversion penalty even for apps that don't use sRGB.
On 1/22/20 15:16, Stefan Dösinger wrote:
utils.c, check_fbo_compat() and the internalformat_query2 equivalents:
if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE]) format->internal = format->srgb_internal;
That's because EXT_texture_sRGB_decode can only switch sRGB off for sRGB textures, it can't switch it on for RGB textures. So we create all as sRGB and switch it off until the app enables it.
We have a fallback codepath in case EXT_TEXTURE_SRGB_DECODE is not available. We'd have to enable this fallback codepath for 16 bit formats, otherwise all 16 bit RGB textures will have the 32 bit conversion penalty even for apps that don't use sRGB.
Oh yeah, thanks. So maybe I introduce that fallback code path for 16 bit SRGB formats then? Or fixup the colour in GLSL (this looks more messy to me at the first glance, not sure it worth adding an extra shader setting for that at the first place and also it will further complicate SRGB handling logic)? Or ignore that bug for now as there is anyway a workaround possible by faking AMD card through registry?
Am 22.01.20 um 13:44 schrieb Paul Gofman:
Oh yeah, thanks. So maybe I introduce that fallback code path for 16 bit SRGB formats then? Or fixup the colour in GLSL (this looks more messy to me at the first glance, not sure it worth adding an extra shader setting for that at the first place and also it will further complicate SRGB handling logic)? Or ignore that bug for now as there is anyway a workaround possible by faking AMD card through registry?
I like the idea of enabling that fallback, although I am not sure what's the cleanest way though. I guess a pile of gl_info->supported[EXT_TEXTURE_SRGB_DECODE] could be replaced by format.internal == format.sRGB_internal checks. The assignment logic if EXT_TEXTURE_SRGB_DECODE needs to be adjusted to just do it for formats with native support, while still allowing advertising the format as supported to the game. There are also potential pitfalls with FRAMEBUFFER_sRGB. Afaik we advertise sRGB write correction only if we can do EXT_TEXTURE_SRGB_DECODE switching because FRAMEBUFFER_sRGB only works on sRGB internal formats.
I'm sure you'll figure something out :-)
GLSL seems overkill. It would add extra shader state logic that seems more complicated than changing the texture format code. Ignoring a bug is always ugly.
On 1/22/20 15:54, Stefan Dösinger wrote:
Am 22.01.20 um 13:44 schrieb Paul Gofman:
I like the idea of enabling that fallback, although I am not sure what's the cleanest way though. I guess a pile of gl_info->supported[EXT_TEXTURE_SRGB_DECODE] could be replaced by format.internal == format.sRGB_internal checks. The assignment logic if EXT_TEXTURE_SRGB_DECODE needs to be adjusted to just do it for formats with native support, while still allowing advertising the format as supported to the game. There are also potential pitfalls with FRAMEBUFFER_sRGB. Afaik we advertise sRGB write correction only if we can do EXT_TEXTURE_SRGB_DECODE switching because FRAMEBUFFER_sRGB only works on sRGB internal formats.
I'm sure you'll figure something out :-)
I guess a change to needs_separate_srgb_gl_texture() in wined3d_private.h involving the format check will act as a main trigger for fallback logic. Then I need to surf through each EXT_TEXTURE_SRGB_DECODE and d3d_info->srgb_read_control check to see what needs to be adjusted on case by case basis. I don't think its a lot, as mostly these checks affect setting GL_TEXTURE_SRGB_DECODE_EXT GL sampler parameter which has no effect on non SRGB format anyway.
On Wed, 22 Jan 2020 at 16:33, Paul Gofman gofmanp@gmail.com wrote:
On 1/22/20 15:54, Stefan Dösinger wrote:
I like the idea of enabling that fallback, although I am not sure what's the cleanest way though. I guess a pile of gl_info->supported[EXT_TEXTURE_SRGB_DECODE] could be replaced by format.internal == format.sRGB_internal checks. The assignment logic if EXT_TEXTURE_SRGB_DECODE needs to be adjusted to just do it for formats with native support, while still allowing advertising the format as supported to the game. There are also potential pitfalls with FRAMEBUFFER_sRGB. Afaik we advertise sRGB write correction only if we can do EXT_TEXTURE_SRGB_DECODE switching because FRAMEBUFFER_sRGB only works on sRGB internal formats.
I'm sure you'll figure something out :-)
I guess a change to needs_separate_srgb_gl_texture() in wined3d_private.h involving the format check will act as a main trigger for fallback logic. Then I need to surf through each EXT_TEXTURE_SRGB_DECODE and d3d_info->srgb_read_control check to see what needs to be adjusted on case by case basis. I don't think its a lot, as mostly these checks affect setting GL_TEXTURE_SRGB_DECODE_EXT GL sampler parameter which has no effect on non SRGB format anyway.
I suspect it's not worth it in terms of making the code more complex; it isn't all that straightforward to start with, as you've found. I'm tempted to just take the hit of using GL_SRGB8 for these formats, unfortunate as that may be.
On 1/22/20 19:39, Henri Verbeet wrote:
On Wed, 22 Jan 2020 at 16:33, Paul Gofman gofmanp@gmail.com wrote:
I guess a change to needs_separate_srgb_gl_texture() in wined3d_private.h involving the format check will act as a main trigger for fallback logic. Then I need to surf through each EXT_TEXTURE_SRGB_DECODE and d3d_info->srgb_read_control check to see what needs to be adjusted on case by case basis. I don't think its a lot, as mostly these checks affect setting GL_TEXTURE_SRGB_DECODE_EXT GL sampler parameter which has no effect on non SRGB format anyway.
I suspect it's not worth it in terms of making the code more complex; it isn't all that straightforward to start with, as you've found. I'm tempted to just take the hit of using GL_SRGB8 for these formats, unfortunate as that may be.
Frankly making (almost) all 16 bit d3d formats always use 24 or 32 bit GL formats is not what I would suggest at start if realized that at once. But if to go that way the first version of my patches are still valid suggestion. Maybe patches 3, 4 can be dropped as that was added for completeness, I am not aware of the real applications depending on that.