Nikolay Sivov : d3dx9: Implement ID3DXTextureShader::GetFunction().
Alexandre Julliard
julliard at winehq.org
Fri Oct 15 15:40:04 CDT 2021
Module: wine
Branch: master
Commit: e3d42ca3033551b99816f812bdc491fc60988ec1
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e3d42ca3033551b99816f812bdc491fc60988ec1
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Fri Oct 15 12:17:52 2021 +0200
d3dx9: Implement ID3DXTextureShader::GetFunction().
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/d3dx9_36/shader.c | 28 ++++++++++++++++++++++++----
dlls/d3dx9_36/tests/texture.c | 34 ++++++++++++++++++++++++++++++++--
2 files changed, 56 insertions(+), 6 deletions(-)
diff --git a/dlls/d3dx9_36/shader.c b/dlls/d3dx9_36/shader.c
index fe0f99180ac..d5b58222ca2 100644
--- a/dlls/d3dx9_36/shader.c
+++ b/dlls/d3dx9_36/shader.c
@@ -2349,6 +2349,8 @@ struct d3dx9_texture_shader
{
ID3DXTextureShader ID3DXTextureShader_iface;
LONG ref;
+
+ ID3DXBuffer *byte_code;
};
static inline struct d3dx9_texture_shader *impl_from_ID3DXTextureShader(ID3DXTextureShader *iface)
@@ -2392,6 +2394,8 @@ static ULONG WINAPI d3dx9_texture_shader_Release(ID3DXTextureShader *iface)
if (!refcount)
{
+ if (texture_shader->byte_code)
+ ID3DXBuffer_Release(texture_shader->byte_code);
HeapFree(GetProcessHeap(), 0, texture_shader);
}
@@ -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)
{
- 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)
@@ -2594,19 +2603,30 @@ static const struct ID3DXTextureShaderVtbl d3dx9_texture_shader_vtbl =
HRESULT WINAPI D3DXCreateTextureShader(const DWORD *function, ID3DXTextureShader **texture_shader)
{
struct d3dx9_texture_shader *object;
+ unsigned int size;
+ HRESULT hr;
TRACE("function %p, texture_shader %p.\n", function, texture_shader);
if (!function || !texture_shader)
return D3DERR_INVALIDCALL;
- object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object));
- if (!object)
+ if (!(size = D3DXGetShaderSize(function)))
+ return D3DXERR_INVALIDDATA;
+
+ if (!(object = heap_alloc_zero(sizeof(*object))))
return E_OUTOFMEMORY;
object->ID3DXTextureShader_iface.lpVtbl = &d3dx9_texture_shader_vtbl;
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;
return D3D_OK;
diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c
index bec7ba48279..26e5aa3dbb6 100644
--- a/dlls/d3dx9_36/tests/texture.c
+++ b/dlls/d3dx9_36/tests/texture.c
@@ -2353,17 +2353,20 @@ float4 main(float3 pos : POSITION, float3 size : PSIZE) : COLOR
};
IDirect3DVolumeTexture9 *volume_texture;
IDirect3DCubeTexture9 *cube_texture;
+ D3DXCONSTANTTABLE_DESC ctab_desc;
+ ID3DXBuffer *buffer, *buffer2;
D3DPRESENT_PARAMETERS d3dpp;
IDirect3DTexture9 *texture;
IDirect3DDevice9 *device;
ID3DXTextureShader *tx;
unsigned int x, y, z;
- ID3DXBuffer *buffer;
unsigned int *data;
D3DLOCKED_RECT lr;
D3DLOCKED_BOX lb;
IDirect3D9 *d3d;
D3DCAPS9 caps;
+ D3DXHANDLE h;
+ DWORD size;
HRESULT hr;
HWND wnd;
@@ -2386,15 +2389,42 @@ float4 main(float3 pos : POSITION, float3 size : PSIZE) : COLOR
ok(SUCCEEDED(hr), "Got unexpected hr %#x.\n", hr);
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))
{
skip("Texture shaders not supported, skipping further tests.\n");
IUnknown_Release(tx);
return;
}
+
+ size = ID3DXBuffer_GetBufferSize(buffer);
+ ok(!size, "Unexpected buffer size %u.\n", size);
+
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,
640, 480, NULL, NULL, NULL, NULL)))
{
More information about the wine-cvs
mailing list