[PATCH 0/4] MR9939: wined3d/hlsl: Implement generated texcoords.
From: Elizabeth Figura <zfigura@codeweavers.com> --- dlls/wined3d/glsl_shader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 3eae2225734..4ae80cf59f3 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -9337,7 +9337,7 @@ static GLuint shader_glsl_generate_ffp_vertex_shader(struct shader_glsl_priv *pr case WINED3DTSS_TCI_SPHEREMAP: shader_addline(buffer, "r = reflect(ffp_normalize(ec_pos.xyz), normal);\n"); - shader_addline(buffer, "m = 2.0 * length(vec3(r.x, r.y, r.z + 1.0));\n"); + shader_addline(buffer, "m = 2.0 * length(vec3(r.x, r.y, r.z - 1.0));\n"); shader_addline(texcoord, "vec4(r.x / m + 0.5, r.y / m + 0.5, 0.0, 1.0)"); break; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9939
From: Elizabeth Figura <zfigura@codeweavers.com> --- dlls/d3d8/tests/visual.c | 94 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c index f1e648a9e09..4f4273a8159 100644 --- a/dlls/d3d8/tests/visual.c +++ b/dlls/d3d8/tests/visual.c @@ -12552,6 +12552,99 @@ static void test_lighting_matrices(void) release_test_context(&context); } +static void test_generated_texcoords(void) +{ + struct d3d8_test_context context; + IDirect3DDevice8 *device; + unsigned int color; + HRESULT hr; + DWORD ps; + + static const DWORD ps_code[] = + { + 0xffff0101, /* ps_1_1 */ + 0x00000040, 0xb00f0000, /* texcoord t0 */ + 0x00000001, 0x800f0000, 0xb0e40000, /* mov r0, t0 */ + 0x0000ffff + }; + + /* Shift a little to show that we're using camera space coordinates. */ + static const D3DMATRIX transform = + {{{ + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.2f, 0.2f, 0.0f, 1.0f, + }}}; + + static const struct + { + struct vec3 position; + struct vec3 normal; + } + tri[] = + { + {{ 2.0f, -2.0f, 0.1f}, {0.8f, 0.0f, 0.7f}}, + {{-2.0f, -2.0f, 0.1f}, {0.8f, 0.0f, 0.7f}}, + {{ 0.0f, 2.0f, 0.1f}, {0.8f, 0.0f, 0.7f}}, + }; + + static const struct + { + unsigned int tci; + unsigned int color; + } + tests[] = + { + {D3DTSS_TCI_CAMERASPACEPOSITION, 0x0000001a}, + {D3DTSS_TCI_CAMERASPACENORMAL, 0x00cc00b2}, + {D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR, 0x0000000f}, + }; + + if (!init_test_context(&context)) + return; + device = context.device; + + hr = IDirect3DDevice8_CreatePixelShader(device, ps_code, &ps); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_SetPixelShader(device, ps); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_NORMAL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ZENABLE, FALSE); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_SetTransform(device, D3DTS_WORLD, &transform); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_SetTransform(device, D3DTS_VIEW, &transform); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + for (unsigned int i = 0; i < ARRAY_SIZE(tests); ++i) + { + winetest_push_context("TCI %#x", tests[i].tci); + + hr = IDirect3DDevice8_SetTextureStageState(device, 0, D3DTSS_TEXCOORDINDEX, tests[i].tci); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_BeginScene(device); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 1, tri, sizeof(*tri)); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice8_EndScene(device); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + color = getPixelColor(device, 320, 240); + ok(color_match(color, tests[i].color, 1), "Got color %08x.\n", color); + + winetest_pop_context(); + } + + release_test_context(&context); +} + START_TEST(visual) { D3DADAPTER_IDENTIFIER8 identifier; @@ -12648,4 +12741,5 @@ START_TEST(visual) test_mipmap_upload(); test_specular_shaders(); test_lighting_matrices(); + test_generated_texcoords(); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9939
From: Elizabeth Figura <zfigura@codeweavers.com> --- dlls/d3d9/tests/visual.c | 96 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index ade80fbe9a1..11b31c9ba13 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -29016,6 +29016,101 @@ static void test_lighting_matrices(void) release_test_context(&context); } +static void test_generated_texcoords(void) +{ + struct d3d9_test_context context; + IDirect3DPixelShader9 *ps; + IDirect3DDevice9 *device; + unsigned int color; + HRESULT hr; + + static const DWORD ps_code[] = + { + 0xffff0101, /* ps_1_1 */ + 0x00000040, 0xb00f0000, /* texcoord t0 */ + 0x00000001, 0x800f0000, 0xb0e40000, /* mov r0, t0 */ + 0x0000ffff + }; + + /* Shift a little to show that we're using camera space coordinates. */ + static const D3DMATRIX transform = + {{{ + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.2f, 0.2f, 0.0f, 1.0f, + }}}; + + static const struct + { + struct vec3 position; + struct vec3 normal; + } + tri[] = + { + {{ 2.0f, -2.0f, 0.1f}, {0.8f, 0.0f, 0.7f}}, + {{-2.0f, -2.0f, 0.1f}, {0.8f, 0.0f, 0.7f}}, + {{ 0.0f, 2.0f, 0.1f}, {0.8f, 0.0f, 0.7f}}, + }; + + static const struct + { + unsigned int tci; + unsigned int color; + } + tests[] = + { + {D3DTSS_TCI_CAMERASPACEPOSITION, 0x0000001a}, + {D3DTSS_TCI_CAMERASPACENORMAL, 0x00cc00b2}, + {D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR, 0x0000000f}, + {D3DTSS_TCI_SPHEREMAP, 0x00836900}, + }; + + if (!init_test_context(&context)) + return; + device = context.device; + + hr = IDirect3DDevice9_CreatePixelShader(device, ps_code, &ps); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetPixelShader(device, ps); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_NORMAL); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, FALSE); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, &transform); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_SetTransform(device, D3DTS_VIEW, &transform); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + for (unsigned int i = 0; i < ARRAY_SIZE(tests); ++i) + { + winetest_push_context("TCI %#x", tests[i].tci); + + hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_TEXCOORDINDEX, tests[i].tci); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xffffffff, 0.0f, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 1, tri, sizeof(*tri)); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + color = getPixelColor(device, 320, 240); + ok(color_match(color, tests[i].color, 1), "Got color %08x.\n", color); + + winetest_pop_context(); + } + + IDirect3DPixelShader9_Release(ps); + release_test_context(&context); +} + START_TEST(visual) { D3DADAPTER_IDENTIFIER9 identifier; @@ -29176,4 +29271,5 @@ START_TEST(visual) test_fog(); test_texture_transform_flags(); test_lighting_matrices(); + test_generated_texcoords(); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9939
From: Elizabeth Figura <zfigura@codeweavers.com> --- dlls/wined3d/ffp_hlsl.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/dlls/wined3d/ffp_hlsl.c b/dlls/wined3d/ffp_hlsl.c index dd03eeea793..7f834e72d10 100644 --- a/dlls/wined3d/ffp_hlsl.c +++ b/dlls/wined3d/ffp_hlsl.c @@ -329,6 +329,24 @@ static bool ffp_hlsl_generate_vertex_shader(const struct wined3d_ffp_vs_settings continue; break; + case WINED3DTSS_TCI_CAMERASPACENORMAL: + shader_addline(&texcoord, "float4(normal, 1.0)"); + break; + + case WINED3DTSS_TCI_CAMERASPACEPOSITION: + shader_addline(&texcoord, "ec_pos"); + break; + + case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR: + shader_addline(&texcoord, "float4(reflect(ffp_normalize(ec_pos.xyz), normal), 1.0)"); + break; + + case WINED3DTSS_TCI_SPHEREMAP: + shader_addline(buffer, "float3 r = reflect(ffp_normalize(ec_pos.xyz), normal);"); + shader_addline(buffer, "float m = 2.0 * length(float3(r.xy, r.z - 1.0));"); + shader_addline(&texcoord, "float4(r.xy / m + 0.5, 0.0, 1.0)"); + break; + default: FIXME("Unhandled texgen %#x.\n", settings->texgen[i]); break; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9939
participants (2)
-
Elizabeth Figura -
Elizabeth Figura (@zfigura)