Commit e3d42ca3 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d3dx9: Implement ID3DXTextureShader::GetFunction().

parent 4ae00bcc
...@@ -2349,6 +2349,8 @@ struct d3dx9_texture_shader ...@@ -2349,6 +2349,8 @@ struct d3dx9_texture_shader
{ {
ID3DXTextureShader ID3DXTextureShader_iface; ID3DXTextureShader ID3DXTextureShader_iface;
LONG ref; LONG ref;
ID3DXBuffer *byte_code;
}; };
static inline struct d3dx9_texture_shader *impl_from_ID3DXTextureShader(ID3DXTextureShader *iface) static inline struct d3dx9_texture_shader *impl_from_ID3DXTextureShader(ID3DXTextureShader *iface)
...@@ -2392,6 +2394,8 @@ static ULONG WINAPI d3dx9_texture_shader_Release(ID3DXTextureShader *iface) ...@@ -2392,6 +2394,8 @@ static ULONG WINAPI d3dx9_texture_shader_Release(ID3DXTextureShader *iface)
if (!refcount) if (!refcount)
{ {
if (texture_shader->byte_code)
ID3DXBuffer_Release(texture_shader->byte_code);
HeapFree(GetProcessHeap(), 0, texture_shader); HeapFree(GetProcessHeap(), 0, texture_shader);
} }
...@@ -2400,9 +2404,14 @@ static ULONG WINAPI d3dx9_texture_shader_Release(ID3DXTextureShader *iface) ...@@ -2400,9 +2404,14 @@ static ULONG WINAPI d3dx9_texture_shader_Release(ID3DXTextureShader *iface)
static HRESULT WINAPI d3dx9_texture_shader_GetFunction(ID3DXTextureShader *iface, struct ID3DXBuffer **function) static HRESULT WINAPI d3dx9_texture_shader_GetFunction(ID3DXTextureShader *iface, struct ID3DXBuffer **function)
{ {
FIXME("iface %p, function %p stub.\n", iface, function); struct d3dx9_texture_shader *texture_shader = impl_from_ID3DXTextureShader(iface);
return E_NOTIMPL; TRACE("iface %p, function %p.\n", iface, function);
*function = texture_shader->byte_code;
ID3DXBuffer_AddRef(*function);
return S_OK;
} }
static HRESULT WINAPI d3dx9_texture_shader_GetConstantBuffer(ID3DXTextureShader *iface, struct ID3DXBuffer **constant_buffer) static HRESULT WINAPI d3dx9_texture_shader_GetConstantBuffer(ID3DXTextureShader *iface, struct ID3DXBuffer **constant_buffer)
...@@ -2594,19 +2603,30 @@ static const struct ID3DXTextureShaderVtbl d3dx9_texture_shader_vtbl = ...@@ -2594,19 +2603,30 @@ static const struct ID3DXTextureShaderVtbl d3dx9_texture_shader_vtbl =
HRESULT WINAPI D3DXCreateTextureShader(const DWORD *function, ID3DXTextureShader **texture_shader) HRESULT WINAPI D3DXCreateTextureShader(const DWORD *function, ID3DXTextureShader **texture_shader)
{ {
struct d3dx9_texture_shader *object; struct d3dx9_texture_shader *object;
unsigned int size;
HRESULT hr;
TRACE("function %p, texture_shader %p.\n", function, texture_shader); TRACE("function %p, texture_shader %p.\n", function, texture_shader);
if (!function || !texture_shader) if (!function || !texture_shader)
return D3DERR_INVALIDCALL; return D3DERR_INVALIDCALL;
object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object)); if (!(size = D3DXGetShaderSize(function)))
if (!object) return D3DXERR_INVALIDDATA;
if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
object->ID3DXTextureShader_iface.lpVtbl = &d3dx9_texture_shader_vtbl; object->ID3DXTextureShader_iface.lpVtbl = &d3dx9_texture_shader_vtbl;
object->ref = 1; object->ref = 1;
if (FAILED(hr = D3DXCreateBuffer(size, &object->byte_code)))
{
IUnknown_Release(&object->ID3DXTextureShader_iface);
return hr;
}
memcpy(ID3DXBuffer_GetBufferPointer(object->byte_code), function, size);
*texture_shader = &object->ID3DXTextureShader_iface; *texture_shader = &object->ID3DXTextureShader_iface;
return D3D_OK; return D3D_OK;
......
...@@ -2353,17 +2353,20 @@ float4 main(float3 pos : POSITION, float3 size : PSIZE) : COLOR ...@@ -2353,17 +2353,20 @@ float4 main(float3 pos : POSITION, float3 size : PSIZE) : COLOR
}; };
IDirect3DVolumeTexture9 *volume_texture; IDirect3DVolumeTexture9 *volume_texture;
IDirect3DCubeTexture9 *cube_texture; IDirect3DCubeTexture9 *cube_texture;
D3DXCONSTANTTABLE_DESC ctab_desc;
ID3DXBuffer *buffer, *buffer2;
D3DPRESENT_PARAMETERS d3dpp; D3DPRESENT_PARAMETERS d3dpp;
IDirect3DTexture9 *texture; IDirect3DTexture9 *texture;
IDirect3DDevice9 *device; IDirect3DDevice9 *device;
ID3DXTextureShader *tx; ID3DXTextureShader *tx;
unsigned int x, y, z; unsigned int x, y, z;
ID3DXBuffer *buffer;
unsigned int *data; unsigned int *data;
D3DLOCKED_RECT lr; D3DLOCKED_RECT lr;
D3DLOCKED_BOX lb; D3DLOCKED_BOX lb;
IDirect3D9 *d3d; IDirect3D9 *d3d;
D3DCAPS9 caps; D3DCAPS9 caps;
D3DXHANDLE h;
DWORD size;
HRESULT hr; HRESULT hr;
HWND wnd; HWND wnd;
...@@ -2386,15 +2389,42 @@ float4 main(float3 pos : POSITION, float3 size : PSIZE) : COLOR ...@@ -2386,15 +2389,42 @@ float4 main(float3 pos : POSITION, float3 size : PSIZE) : COLOR
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr); ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
hr = tx->lpVtbl->GetFunction(tx, &buffer); hr = tx->lpVtbl->GetFunction(tx, &buffer);
todo_wine ok(SUCCEEDED(hr), "Failed to get texture shader bytecode.\n"); ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
hr = tx->lpVtbl->GetFunction(tx, &buffer2);
ok(hr == D3D_OK, "Unexpected hr %#x.\n", hr);
ok(buffer2 == buffer, "Unexpected buffer object.\n");
ID3DXBuffer_Release(buffer2);
size = ID3DXBuffer_GetBufferSize(buffer);
ok(size == 224, "Unexpected buffer size %u.\n", size);
ID3DXBuffer_Release(buffer);
/* Constant buffer */
hr = tx->lpVtbl->GetConstantBuffer(tx, &buffer);
todo_wine
ok(SUCCEEDED(hr), "Failed to get texture shader constant buffer.\n");
if (FAILED(hr)) if (FAILED(hr))
{ {
skip("Texture shaders not supported, skipping further tests.\n"); skip("Texture shaders not supported, skipping further tests.\n");
IUnknown_Release(tx); IUnknown_Release(tx);
return; return;
} }
size = ID3DXBuffer_GetBufferSize(buffer);
ok(!size, "Unexpected buffer size %u.\n", size);
ID3DXBuffer_Release(buffer); ID3DXBuffer_Release(buffer);
hr = tx->lpVtbl->GetDesc(tx, &ctab_desc);
ok(hr == S_OK, "Failed to get constant description, hr %#x.\n", hr);
ok(!ctab_desc.Constants, "Unexpected number of constants %u.\n", ctab_desc.Constants);
/* Constant table access calls, without constant table. */
h = tx->lpVtbl->GetConstant(tx, NULL, 0);
ok(!h, "Unexpected handle %p.\n", h);
if (!(wnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0, if (!(wnd = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0,
640, 480, NULL, NULL, NULL, NULL))) 640, 480, NULL, NULL, NULL, NULL)))
{ {
......
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