Commit b31b9864 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

d3dx9: Fix ID3DXConstantTable::SetMatrix.

parent 53ce2a24
...@@ -1178,7 +1178,7 @@ static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrix(ID3DXConstantTable *iface ...@@ -1178,7 +1178,7 @@ static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrix(ID3DXConstantTable *iface
TRACE("(%p)->(%p, %p, %p)\n", This, device, constant, matrix); TRACE("(%p)->(%p, %p, %p)\n", This, device, constant, matrix);
return ID3DXConstantTable_SetMatrixArray(iface, device, constant, matrix, 1); return set_matrix_array(iface, device, constant, matrix, 1, D3DXPT_FLOAT, 4, 4);
} }
static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixArray(ID3DXConstantTable *iface, LPDIRECT3DDEVICE9 device, static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixArray(ID3DXConstantTable *iface, LPDIRECT3DDEVICE9 device,
...@@ -1186,41 +1186,9 @@ static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixArray(ID3DXConstantTable * ...@@ -1186,41 +1186,9 @@ static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixArray(ID3DXConstantTable *
{ {
struct ID3DXConstantTableImpl *This = impl_from_ID3DXConstantTable(iface); struct ID3DXConstantTableImpl *This = impl_from_ID3DXConstantTable(iface);
D3DXCONSTANT_DESC desc;
HRESULT hr;
UINT i, desc_count = 1;
D3DXMATRIX temp;
TRACE("(%p)->(%p, %p, %p, %d)\n", This, device, constant, matrix, count); TRACE("(%p)->(%p, %p, %p, %d)\n", This, device, constant, matrix, count);
hr = ID3DXConstantTable_GetConstantDesc(iface, constant, &desc, &desc_count); return set_matrix_array(iface, device, constant, matrix, count, D3DXPT_FLOAT, 4, 4);
if (FAILED(hr))
{
TRACE("ID3DXConstantTable_GetConstantDesc failed: %08x\n", hr);
return D3DERR_INVALIDCALL;
}
switch (desc.RegisterSet)
{
case D3DXRS_FLOAT4:
/* i * 4 + 3 is the last register we set. The conditional makes sure that we don't access
registers we're not supposed to */
for (i = 0; i < count && i * 4 + 3 < desc.RegisterCount; i++)
{
if (desc.Class == D3DXPC_MATRIX_ROWS)
temp = matrix[i];
else
D3DXMatrixTranspose(&temp, &matrix[i]);
set_float_shader_constant(This, device, desc.RegisterIndex + i * 4, &temp.u.s._11, 4);
}
break;
default:
FIXME("Handle other register sets\n");
return E_NOTIMPL;
}
return D3D_OK;
} }
static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixPointerArray(ID3DXConstantTable *iface, LPDIRECT3DDEVICE9 device, static HRESULT WINAPI ID3DXConstantTableImpl_SetMatrixPointerArray(ID3DXConstantTable *iface, LPDIRECT3DDEVICE9 device,
......
...@@ -674,7 +674,7 @@ static void test_setting_matrices_table(IDirect3DDevice9 *device) ...@@ -674,7 +674,7 @@ static void test_setting_matrices_table(IDirect3DDevice9 *device)
(int)S(U(fmatrix))._21, (int)S(U(fmatrix))._22, (int)S(U(fmatrix))._23, 0); (int)S(U(fmatrix))._21, (int)S(U(fmatrix))._22, (int)S(U(fmatrix))._23, 0);
IDirect3DDevice9_GetVertexShaderConstantF(device, 7, out, 1); IDirect3DDevice9_GetVertexShaderConstantF(device, 7, out, 1);
todo_wine ok(out[0] == S(U(fmatrix))._11 && out[1] == S(U(fmatrix))._21 && out[2] == S(U(fmatrix))._31 && out[3] == 0.0f, ok(out[0] == S(U(fmatrix))._11 && out[1] == S(U(fmatrix))._21 && out[2] == S(U(fmatrix))._31 && out[3] == 0.0f,
"The variable fmatrix3x1 was not set correctly, out={%f, %f, %f, %f}, should be {%f, %f, %f, %f}\n", "The variable fmatrix3x1 was not set correctly, out={%f, %f, %f, %f}, should be {%f, %f, %f, %f}\n",
out[0], out[1], out[2], out[3], out[0], out[1], out[2], out[3],
S(U(fmatrix))._11, S(U(fmatrix))._21, S(U(fmatrix))._31, 0.0f); S(U(fmatrix))._11, S(U(fmatrix))._21, S(U(fmatrix))._31, 0.0f);
...@@ -700,7 +700,7 @@ static void test_setting_matrices_table(IDirect3DDevice9 *device) ...@@ -700,7 +700,7 @@ static void test_setting_matrices_table(IDirect3DDevice9 *device)
ok(res == D3D_OK, "ID3DXConstantTable_SetMatrix failed on variable c3x3: got %#x\n", res); ok(res == D3D_OK, "ID3DXConstantTable_SetMatrix failed on variable c3x3: got %#x\n", res);
IDirect3DDevice9_GetVertexShaderConstantF(device, 7, out, 3); IDirect3DDevice9_GetVertexShaderConstantF(device, 7, out, 3);
todo_wine ok(out[0] == S(U(fmatrix))._11 && out[1] == S(U(fmatrix))._21 && out[2] == 0.0f && out[3] == 0.0f ok(out[0] == S(U(fmatrix))._11 && out[1] == S(U(fmatrix))._21 && out[2] == 0.0f && out[3] == 0.0f
&& out[4] == S(U(fmatrix))._12 && out[5] == S(U(fmatrix))._22 && out[6] == 0.0f && out[7] == 0.0f && out[4] == S(U(fmatrix))._12 && out[5] == S(U(fmatrix))._22 && out[6] == 0.0f && out[7] == 0.0f
&& out[8] == S(U(fmatrix))._13 && out[9] == S(U(fmatrix))._23 && out[10] == 0.0f && out[11] == 0.0f, && out[8] == S(U(fmatrix))._13 && out[9] == S(U(fmatrix))._23 && out[10] == 0.0f && out[11] == 0.0f,
"The variable c2x3 was not set correctly, out={%f, %f, %f, %f; %f, %f, %f, %f; %f, %f, %f, %f}, " "The variable c2x3 was not set correctly, out={%f, %f, %f, %f; %f, %f, %f, %f; %f, %f, %f, %f}, "
...@@ -716,7 +716,7 @@ static void test_setting_matrices_table(IDirect3DDevice9 *device) ...@@ -716,7 +716,7 @@ static void test_setting_matrices_table(IDirect3DDevice9 *device)
ok(res == D3D_OK, "ID3DXConstantTable_SetMatrix failed on variable r4x4: got %#x\n", res); ok(res == D3D_OK, "ID3DXConstantTable_SetMatrix failed on variable r4x4: got %#x\n", res);
IDirect3DDevice9_GetVertexShaderConstantF(device, 15, out, 2); IDirect3DDevice9_GetVertexShaderConstantF(device, 15, out, 2);
todo_wine ok(out[0] == S(U(fmatrix))._11 && out[1] == S(U(fmatrix))._12 && out[2] == S(U(fmatrix))._13 && out[3] == 0.0f ok(out[0] == S(U(fmatrix))._11 && out[1] == S(U(fmatrix))._12 && out[2] == S(U(fmatrix))._13 && out[3] == 0.0f
&& out[4] == S(U(fmatrix))._21 && out[5] == S(U(fmatrix))._22 && out[6] == S(U(fmatrix))._23 && out[7] == 0.0f, && out[4] == S(U(fmatrix))._21 && out[5] == S(U(fmatrix))._22 && out[6] == S(U(fmatrix))._23 && out[7] == 0.0f,
"The variable r2x3 was not set correctly, out={%f, %f, %f, %f; %f, %f, %f, %f}, " "The variable r2x3 was not set correctly, out={%f, %f, %f, %f; %f, %f, %f, %f}, "
"should be {%f, %f, %f, %f; %f, %f, %f, %f}\n", "should be {%f, %f, %f, %f; %f, %f, %f, %f}\n",
...@@ -725,7 +725,7 @@ static void test_setting_matrices_table(IDirect3DDevice9 *device) ...@@ -725,7 +725,7 @@ static void test_setting_matrices_table(IDirect3DDevice9 *device)
S(U(fmatrix))._21, S(U(fmatrix))._22, S(U(fmatrix))._23, 0.0f); S(U(fmatrix))._21, S(U(fmatrix))._22, S(U(fmatrix))._23, 0.0f);
IDirect3DDevice9_GetVertexShaderConstantF(device, 13, out, 2); IDirect3DDevice9_GetVertexShaderConstantF(device, 13, out, 2);
todo_wine ok(out[0] == S(U(fmatrix))._11 && out[1] == S(U(fmatrix))._21 && out[2] == S(U(fmatrix))._31 && out[3] == 0.0f ok(out[0] == S(U(fmatrix))._11 && out[1] == S(U(fmatrix))._21 && out[2] == S(U(fmatrix))._31 && out[3] == 0.0f
&& out[4] == S(U(fmatrix))._12 && out[5] == S(U(fmatrix))._22 && out[6] == S(U(fmatrix))._32 && out[7] == 0.0f, && out[4] == S(U(fmatrix))._12 && out[5] == S(U(fmatrix))._22 && out[6] == S(U(fmatrix))._32 && out[7] == 0.0f,
"The variable c3x2 was not set correctly, out={%f, %f, %f, %f; %f, %f, %f, %f}, " "The variable c3x2 was not set correctly, out={%f, %f, %f, %f; %f, %f, %f, %f}, "
"should be {%f, %f, %f, %f; %f, %f, %f, %f}\n", "should be {%f, %f, %f, %f; %f, %f, %f, %f}\n",
...@@ -734,7 +734,7 @@ static void test_setting_matrices_table(IDirect3DDevice9 *device) ...@@ -734,7 +734,7 @@ static void test_setting_matrices_table(IDirect3DDevice9 *device)
S(U(fmatrix))._12, S(U(fmatrix))._22, S(U(fmatrix))._32, 0.0f); S(U(fmatrix))._12, S(U(fmatrix))._22, S(U(fmatrix))._32, 0.0f);
IDirect3DDevice9_GetVertexShaderConstantF(device, 4, out, 3); IDirect3DDevice9_GetVertexShaderConstantF(device, 4, out, 3);
todo_wine ok(out[0] == S(U(fmatrix))._11 && out[1] == S(U(fmatrix))._12 && out[2] == 0.0f && out[3] == 0.0f ok(out[0] == S(U(fmatrix))._11 && out[1] == S(U(fmatrix))._12 && out[2] == 0.0f && out[3] == 0.0f
&& out[4] == S(U(fmatrix))._21 && out[5] == S(U(fmatrix))._22 && out[6] == 0.0f && out[7] == 0.0f && out[4] == S(U(fmatrix))._21 && out[5] == S(U(fmatrix))._22 && out[6] == 0.0f && out[7] == 0.0f
&& out[8] == S(U(fmatrix))._31 && out[9] == S(U(fmatrix))._32 && out[10] == 0.0f && out[11] == 0.0f, && out[8] == S(U(fmatrix))._31 && out[9] == S(U(fmatrix))._32 && out[10] == 0.0f && out[11] == 0.0f,
"The variable r3x2 was not set correctly, out={%f, %f, %f, %f; %f, %f, %f, %f; %f, %f, %f, %f}, " "The variable r3x2 was not set correctly, out={%f, %f, %f, %f; %f, %f, %f, %f; %f, %f, %f, %f}, "
...@@ -745,7 +745,7 @@ static void test_setting_matrices_table(IDirect3DDevice9 *device) ...@@ -745,7 +745,7 @@ static void test_setting_matrices_table(IDirect3DDevice9 *device)
S(U(fmatrix))._31, S(U(fmatrix))._32, 0.0f, 0.0f); S(U(fmatrix))._31, S(U(fmatrix))._32, 0.0f, 0.0f);
IDirect3DDevice9_GetVertexShaderConstantF(device, 10, out, 3); IDirect3DDevice9_GetVertexShaderConstantF(device, 10, out, 3);
todo_wine ok(out[0] == S(U(fmatrix))._11 && out[1] == S(U(fmatrix))._21 && out[2] == S(U(fmatrix))._31 && out[3] == 0.0f ok(out[0] == S(U(fmatrix))._11 && out[1] == S(U(fmatrix))._21 && out[2] == S(U(fmatrix))._31 && out[3] == 0.0f
&& out[4] == S(U(fmatrix))._12 && out[5] == S(U(fmatrix))._22 && out[6] == S(U(fmatrix))._32 && out[7] == 0.0f && out[4] == S(U(fmatrix))._12 && out[5] == S(U(fmatrix))._22 && out[6] == S(U(fmatrix))._32 && out[7] == 0.0f
&& out[8] == S(U(fmatrix))._13 && out[9] == S(U(fmatrix))._23 && out[10] == S(U(fmatrix))._33 && out[11] == 0.0f, && out[8] == S(U(fmatrix))._13 && out[9] == S(U(fmatrix))._23 && out[10] == S(U(fmatrix))._33 && out[11] == 0.0f,
"The variable c3x3 was not set correctly, out={%f, %f, %f, %f; %f, %f, %f, %f; %f, %f, %f, %f}, " "The variable c3x3 was not set correctly, out={%f, %f, %f, %f; %f, %f, %f, %f; %f, %f, %f, %f}, "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment