From: Paul Gofman gofmanp@gmail.com
Signed-off-by: Paul Gofman gofmanp@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: Avoid assignments inside function call arguments.
dlls/d3dx9_36/effect.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-)
diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index 63c931e1728..e69a1fd1f87 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -5345,8 +5345,11 @@ static HRESULT d3dx_parse_effect_annotation(struct d3dx_effect *effect, struct d static HRESULT d3dx_parse_state(struct d3dx_effect *effect, struct d3dx_state *state, const char *data, const char **ptr, struct d3dx_object *objects) { - DWORD offset; + struct d3dx_parameter *param = &state->parameter; + enum STATE_CLASS state_class; const char *ptr2; + void *new_data; + DWORD offset; HRESULT hr;
state->type = ST_CONSTANT; @@ -5360,7 +5363,7 @@ static HRESULT d3dx_parse_state(struct d3dx_effect *effect, struct d3dx_state *s read_dword(ptr, &offset); TRACE("Typedef offset: %#x\n", offset); ptr2 = data + offset; - hr = d3dx_parse_effect_typedef(effect, &state->parameter, data, &ptr2, NULL, 0); + hr = d3dx_parse_effect_typedef(effect, param, data, &ptr2, NULL, 0); if (hr != D3D_OK) { WARN("Failed to parse type definition\n"); @@ -5369,18 +5372,42 @@ static HRESULT d3dx_parse_state(struct d3dx_effect *effect, struct d3dx_state *s
read_dword(ptr, &offset); TRACE("Value offset: %#x\n", offset); - hr = d3dx_parse_init_value(effect, &state->parameter, data, data + offset, objects); + hr = d3dx_parse_init_value(effect, param, data, data + offset, objects); if (hr != D3D_OK) { WARN("Failed to parse value\n"); goto err_out; }
+ if (((state_class = state_table[state->operation].class) == SC_VERTEXSHADER + || state_class == SC_PIXELSHADER || state_class == SC_TEXTURE) + && param->bytes < sizeof(void *)) + { + if (param->type != D3DXPT_INT || *(unsigned int *)param->data) + { + FIXME("Unexpected parameter for object, param->type %#x, param->class %#x, *param->data %#x.\n", + param->type, param->class, *(unsigned int *)param->data); + hr = D3DXERR_INVALIDDATA; + goto err_out; + } + + new_data = heap_realloc(param->data, sizeof(void *)); + if (!new_data) + { + ERR("Out of memory.\n"); + hr = E_OUTOFMEMORY; + goto err_out; + } + memset(new_data, 0, sizeof(void *)); + param->data = new_data; + param->bytes = sizeof(void *); + } + return D3D_OK;
err_out:
- free_parameter(&state->parameter, FALSE, FALSE); + free_parameter(param, FALSE, FALSE);
return hr; }
From: Connor McAdams conmanx360@gmail.com
Signed-off-by: Connor McAdams conmanx360@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- This fixes a crash in Crysis when run in DX10 mode.
dlls/d3dx10_43/d3dx10_43.spec | 2 +- dlls/d3dx10_43/d3dx10_43_main.c | 8 ++++++++ include/d3dx10tex.h | 34 +++++++++++++++++++++++++++++++-- 3 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/dlls/d3dx10_43/d3dx10_43.spec b/dlls/d3dx10_43/d3dx10_43.spec index cb491241d4b..36c7633d8e0 100644 --- a/dlls/d3dx10_43/d3dx10_43.spec +++ b/dlls/d3dx10_43/d3dx10_43.spec @@ -54,7 +54,7 @@ @ stdcall D3DX10GetImageInfoFromMemory(ptr long ptr ptr ptr) @ stub D3DX10GetImageInfoFromResourceA(long str ptr ptr ptr) @ stub D3DX10GetImageInfoFromResourceW(long wstr ptr ptr ptr) -@ stub D3DX10LoadTextureFromTexture(ptr ptr ptr) +@ stdcall D3DX10LoadTextureFromTexture(ptr ptr ptr) @ stub D3DX10PreprocessShaderFromFileA(str ptr ptr ptr ptr ptr) @ stub D3DX10PreprocessShaderFromFileW(wstr ptr ptr ptr ptr ptr) @ stdcall D3DX10PreprocessShaderFromMemory(ptr long str ptr ptr ptr ptr ptr ptr) diff --git a/dlls/d3dx10_43/d3dx10_43_main.c b/dlls/d3dx10_43/d3dx10_43_main.c index b0295cc093f..45247756b8e 100644 --- a/dlls/d3dx10_43/d3dx10_43_main.c +++ b/dlls/d3dx10_43/d3dx10_43_main.c @@ -241,3 +241,11 @@ D3DX_CPU_OPTIMIZATION WINAPI D3DXCpuOptimizations(BOOL enable)
return D3DX_NOT_OPTIMIZED; } + +HRESULT WINAPI D3DX10LoadTextureFromTexture(ID3D10Resource *src_texture, D3DX10_TEXTURE_LOAD_INFO *load_info, + ID3D10Resource *dst_texture) +{ + FIXME("src_texture %p, load_info %p, dst_texture %p stub!\n", src_texture, load_info, dst_texture); + + return E_NOTIMPL; +} diff --git a/include/d3dx10tex.h b/include/d3dx10tex.h index 25ad490949a..98cb82c0c93 100644 --- a/include/d3dx10tex.h +++ b/include/d3dx10tex.h @@ -103,17 +103,47 @@ typedef struct D3DX10_IMAGE_LOAD_INFO #endif } D3DX10_IMAGE_LOAD_INFO;
+typedef struct _D3DX10_TEXTURE_LOAD_INFO +{ + D3D10_BOX *pSrcBox; + D3D10_BOX *pDstBox; + UINT SrcFirstMip; + UINT DstFirstMip; + UINT NumMips; + UINT SrcFirstElement; + UINT DstFirstElement; + UINT NumElements; + UINT Filter; + UINT MipFilter; + +#ifdef __cplusplus + _D3DX10_TEXTURE_LOAD_INFO() + { + pSrcBox = NULL; + pDstBox = NULL; + SrcFirstMip = 0; + DstFirstMip = 0; + NumMips = D3DX10_DEFAULT; + SrcFirstElement = 0; + DstFirstElement = 0; + NumElements = D3DX10_DEFAULT; + Filter = D3DX10_DEFAULT; + MipFilter = D3DX10_DEFAULT; + } +#endif +} D3DX10_TEXTURE_LOAD_INFO; + #ifdef __cplusplus extern "C" { #endif
HRESULT WINAPI D3DX10CreateTextureFromMemory(ID3D10Device *device, const void *src_data, SIZE_T src_data_size, D3DX10_IMAGE_LOAD_INFO *loadinfo, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult); - HRESULT WINAPI D3DX10FilterTexture(ID3D10Resource *texture, UINT src_level, UINT filter); - HRESULT WINAPI D3DX10GetImageInfoFromMemory(const void *src_data, SIZE_T src_data_size, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *img_info, HRESULT *hresult); +HRESULT WINAPI D3DX10LoadTextureFromTexture(ID3D10Resource *src_texture, D3DX10_TEXTURE_LOAD_INFO *load_info, + ID3D10Resource *dst_texture);
#ifdef __cplusplus }
From: Liam Middlebrook lmiddlebrook@nvidia.com
Signed-off-by: Liam Middlebrook lmiddlebrook@nvidia.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v3: Add the prototypes to the header, thank you Andrey.
We aren't using "Reviewed-by" tags at the moment so I got rid of Andy Ritger's; the review is appreciated nevertheless. I guess in the future you could sign-off the patch instead, that will be preserved. I didn't feel comfortable in changing the tag myself though.
BTW, do you know (and, can you mention) any specific application that's fixed by this?
dlls/d3dx11_42/d3dx11_42.spec | 4 ++-- dlls/d3dx11_43/d3dx11_43.spec | 4 ++-- dlls/d3dx11_43/texture.c | 18 ++++++++++++++++++ include/d3dx11tex.h | 10 ++++------ 4 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/dlls/d3dx11_42/d3dx11_42.spec b/dlls/d3dx11_42/d3dx11_42.spec index dde8821a304..30bdba42441 100644 --- a/dlls/d3dx11_42/d3dx11_42.spec +++ b/dlls/d3dx11_42/d3dx11_42.spec @@ -39,6 +39,6 @@ @ stub D3DX11PreprocessShaderFromResourceA @ stub D3DX11PreprocessShaderFromResourceW @ stub D3DX11SHProjectCubeMap -@ stub D3DX11SaveTextureToFileA -@ stub D3DX11SaveTextureToFileW +@ stdcall D3DX11SaveTextureToFileA(ptr ptr long str) +@ stdcall D3DX11SaveTextureToFileW(ptr ptr long wstr) @ stdcall D3DX11SaveTextureToMemory(ptr ptr long ptr long) diff --git a/dlls/d3dx11_43/d3dx11_43.spec b/dlls/d3dx11_43/d3dx11_43.spec index dde8821a304..30bdba42441 100644 --- a/dlls/d3dx11_43/d3dx11_43.spec +++ b/dlls/d3dx11_43/d3dx11_43.spec @@ -39,6 +39,6 @@ @ stub D3DX11PreprocessShaderFromResourceA @ stub D3DX11PreprocessShaderFromResourceW @ stub D3DX11SHProjectCubeMap -@ stub D3DX11SaveTextureToFileA -@ stub D3DX11SaveTextureToFileW +@ stdcall D3DX11SaveTextureToFileA(ptr ptr long str) +@ stdcall D3DX11SaveTextureToFileW(ptr ptr long wstr) @ stdcall D3DX11SaveTextureToMemory(ptr ptr long ptr long) diff --git a/dlls/d3dx11_43/texture.c b/dlls/d3dx11_43/texture.c index bc30015102f..ee6808d76d6 100644 --- a/dlls/d3dx11_43/texture.c +++ b/dlls/d3dx11_43/texture.c @@ -63,6 +63,24 @@ HRESULT WINAPI D3DX11CreateTextureFromMemory(ID3D11Device *device, const void *d return E_NOTIMPL; }
+HRESULT WINAPI D3DX11SaveTextureToFileW(ID3D11DeviceContext *context, ID3D11Resource *texture, + D3DX11_IMAGE_FILE_FORMAT format, const WCHAR *filename) +{ + FIXME("context %p, texture %p, format %u, filename %s stub!\n", + context, texture, format, debugstr_w(filename)); + + return E_NOTIMPL; +} + +HRESULT WINAPI D3DX11SaveTextureToFileA(ID3D11DeviceContext *context, ID3D11Resource *texture, + D3DX11_IMAGE_FILE_FORMAT format, const char *filename) +{ + FIXME("context %p, texture %p, format %u, filename %s stub!\n", + context, texture, format, debugstr_a(filename)); + + return E_NOTIMPL; +} + HRESULT WINAPI D3DX11SaveTextureToMemory(ID3D11DeviceContext *context, ID3D11Resource *texture, D3DX11_IMAGE_FILE_FORMAT format, ID3D10Blob **buffer, UINT flags) { diff --git a/include/d3dx11tex.h b/include/d3dx11tex.h index 4f792ec13ef..b7c00ac4fde 100644 --- a/include/d3dx11tex.h +++ b/include/d3dx11tex.h @@ -110,23 +110,21 @@ extern "C" { HRESULT WINAPI D3DX11CreateShaderResourceViewFromMemory(ID3D11Device *device, const void *data, SIZE_T data_size, D3DX11_IMAGE_LOAD_INFO *load_info, ID3DX11ThreadPump *pump, ID3D11ShaderResourceView **view, HRESULT *hresult); - HRESULT WINAPI D3DX11CreateTextureFromFileA(ID3D11Device *device, const char *filename, D3DX11_IMAGE_LOAD_INFO *load_info, ID3DX11ThreadPump *pump, ID3D11Resource **texture, HRESULT *hresult); - HRESULT WINAPI D3DX11CreateTextureFromFileW(ID3D11Device *device, const WCHAR *filename, D3DX11_IMAGE_LOAD_INFO *load_info, ID3DX11ThreadPump *pump, ID3D11Resource **texture, HRESULT *hresult); - HRESULT WINAPI D3DX11CreateTextureFromMemory(ID3D11Device *device, const void *src_data, SIZE_T src_data_size, D3DX11_IMAGE_LOAD_INFO *loadinfo, ID3DX11ThreadPump *pump, ID3D11Resource **texture, HRESULT *hresult); - HRESULT WINAPI D3DX11FilterTexture(ID3D11DeviceContext *context, ID3D11Resource *texture, UINT src_level, UINT filter); - HRESULT WINAPI D3DX11GetImageInfoFromMemory(const void *src_data, SIZE_T src_data_size, ID3DX11ThreadPump *pump, D3DX11_IMAGE_INFO *img_info, HRESULT *hresult); - +HRESULT WINAPI D3DX11SaveTextureToFileA(ID3D11DeviceContext *context, ID3D11Resource *texture, + D3DX11_IMAGE_FILE_FORMAT format, const char *filename); +HRESULT WINAPI D3DX11SaveTextureToFileW(ID3D11DeviceContext *context, ID3D11Resource *texture, + D3DX11_IMAGE_FILE_FORMAT format, const WCHAR *filename); HRESULT WINAPI D3DX11SaveTextureToMemory(ID3D11DeviceContext *context, ID3D11Resource *texture, D3DX11_IMAGE_FILE_FORMAT format, ID3D10Blob **buffer, UINT flags);
On 11/6/19 1:06 AM, Matteo Bruni wrote:
From: Liam Middlebrook lmiddlebrook@nvidia.com
Signed-off-by: Liam Middlebrook lmiddlebrook@nvidia.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com
v3: Add the prototypes to the header, thank you Andrey.
We aren't using "Reviewed-by" tags at the moment so I got rid of Andy Ritger's; the review is appreciated nevertheless. I guess in the future you could sign-off the patch instead, that will be preserved. I didn't feel comfortable in changing the tag myself though.
The "Reviewed-by" tag is an artifact of our Open Source contribution process for mailing lists. A more fitting tag may be "Reviewed-for-public-release-by" albeit a bit wordy. I agree that changing the tag to "Signed-off-by" wouldn't be correct in this case.
BTW, do you know (and, can you mention) any specific application that's fixed by this?
I'm not aware of any publicly available applications which are fixed by this.
Thanks,
Liam Middlebrook
dlls/d3dx11_42/d3dx11_42.spec | 4 ++-- dlls/d3dx11_43/d3dx11_43.spec | 4 ++-- dlls/d3dx11_43/texture.c | 18 ++++++++++++++++++ include/d3dx11tex.h | 10 ++++------ 4 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/dlls/d3dx11_42/d3dx11_42.spec b/dlls/d3dx11_42/d3dx11_42.spec index dde8821a304..30bdba42441 100644 --- a/dlls/d3dx11_42/d3dx11_42.spec +++ b/dlls/d3dx11_42/d3dx11_42.spec @@ -39,6 +39,6 @@ @ stub D3DX11PreprocessShaderFromResourceA @ stub D3DX11PreprocessShaderFromResourceW @ stub D3DX11SHProjectCubeMap -@ stub D3DX11SaveTextureToFileA -@ stub D3DX11SaveTextureToFileW +@ stdcall D3DX11SaveTextureToFileA(ptr ptr long str) +@ stdcall D3DX11SaveTextureToFileW(ptr ptr long wstr) @ stdcall D3DX11SaveTextureToMemory(ptr ptr long ptr long) diff --git a/dlls/d3dx11_43/d3dx11_43.spec b/dlls/d3dx11_43/d3dx11_43.spec index dde8821a304..30bdba42441 100644 --- a/dlls/d3dx11_43/d3dx11_43.spec +++ b/dlls/d3dx11_43/d3dx11_43.spec @@ -39,6 +39,6 @@ @ stub D3DX11PreprocessShaderFromResourceA @ stub D3DX11PreprocessShaderFromResourceW @ stub D3DX11SHProjectCubeMap -@ stub D3DX11SaveTextureToFileA -@ stub D3DX11SaveTextureToFileW +@ stdcall D3DX11SaveTextureToFileA(ptr ptr long str) +@ stdcall D3DX11SaveTextureToFileW(ptr ptr long wstr) @ stdcall D3DX11SaveTextureToMemory(ptr ptr long ptr long) diff --git a/dlls/d3dx11_43/texture.c b/dlls/d3dx11_43/texture.c index bc30015102f..ee6808d76d6 100644 --- a/dlls/d3dx11_43/texture.c +++ b/dlls/d3dx11_43/texture.c @@ -63,6 +63,24 @@ HRESULT WINAPI D3DX11CreateTextureFromMemory(ID3D11Device *device, const void *d return E_NOTIMPL; }
+HRESULT WINAPI D3DX11SaveTextureToFileW(ID3D11DeviceContext *context, ID3D11Resource *texture,
D3DX11_IMAGE_FILE_FORMAT format, const WCHAR *filename)
+{
- FIXME("context %p, texture %p, format %u, filename %s stub!\n",
context, texture, format, debugstr_w(filename));
- return E_NOTIMPL;
+}
+HRESULT WINAPI D3DX11SaveTextureToFileA(ID3D11DeviceContext *context, ID3D11Resource *texture,
D3DX11_IMAGE_FILE_FORMAT format, const char *filename)
+{
- FIXME("context %p, texture %p, format %u, filename %s stub!\n",
context, texture, format, debugstr_a(filename));
- return E_NOTIMPL;
+}
- HRESULT WINAPI D3DX11SaveTextureToMemory(ID3D11DeviceContext *context, ID3D11Resource *texture, D3DX11_IMAGE_FILE_FORMAT format, ID3D10Blob **buffer, UINT flags) {
diff --git a/include/d3dx11tex.h b/include/d3dx11tex.h index 4f792ec13ef..b7c00ac4fde 100644 --- a/include/d3dx11tex.h +++ b/include/d3dx11tex.h @@ -110,23 +110,21 @@ extern "C" { HRESULT WINAPI D3DX11CreateShaderResourceViewFromMemory(ID3D11Device *device, const void *data, SIZE_T data_size, D3DX11_IMAGE_LOAD_INFO *load_info, ID3DX11ThreadPump *pump, ID3D11ShaderResourceView **view, HRESULT *hresult);
- HRESULT WINAPI D3DX11CreateTextureFromFileA(ID3D11Device *device, const char *filename, D3DX11_IMAGE_LOAD_INFO *load_info, ID3DX11ThreadPump *pump, ID3D11Resource **texture, HRESULT *hresult);
- HRESULT WINAPI D3DX11CreateTextureFromFileW(ID3D11Device *device, const WCHAR *filename, D3DX11_IMAGE_LOAD_INFO *load_info, ID3DX11ThreadPump *pump, ID3D11Resource **texture, HRESULT *hresult);
- HRESULT WINAPI D3DX11CreateTextureFromMemory(ID3D11Device *device, const void *src_data, SIZE_T src_data_size, D3DX11_IMAGE_LOAD_INFO *loadinfo, ID3DX11ThreadPump *pump, ID3D11Resource **texture, HRESULT *hresult);
- HRESULT WINAPI D3DX11FilterTexture(ID3D11DeviceContext *context, ID3D11Resource *texture, UINT src_level, UINT filter);
- HRESULT WINAPI D3DX11GetImageInfoFromMemory(const void *src_data, SIZE_T src_data_size, ID3DX11ThreadPump *pump, D3DX11_IMAGE_INFO *img_info, HRESULT *hresult);
+HRESULT WINAPI D3DX11SaveTextureToFileA(ID3D11DeviceContext *context, ID3D11Resource *texture,
D3DX11_IMAGE_FILE_FORMAT format, const char *filename);
+HRESULT WINAPI D3DX11SaveTextureToFileW(ID3D11DeviceContext *context, ID3D11Resource *texture,
HRESULT WINAPI D3DX11SaveTextureToMemory(ID3D11DeviceContext *context, ID3D11Resource *texture, D3DX11_IMAGE_FILE_FORMAT format, ID3D10Blob **buffer, UINT flags);D3DX11_IMAGE_FILE_FORMAT format, const WCHAR *filename);
----------------------------------------------------------------------------------- This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. -----------------------------------------------------------------------------------
From: Connor McAdams conmanx360@gmail.com
Signed-off-by: Connor McAdams conmanx360@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- With the intention of reusing d3dcompiler's implementation for d3d10 in a bit.
After seeing it, I guess I like it better combined in one patch after all... Sorry about that.
dlls/d3d10/Makefile.in | 7 +- dlls/d3d10/d3d10_main.c | 22 ----- dlls/d3d10/d3d10_private.h | 8 -- dlls/d3d10/shader.c | 112 -------------------------- dlls/d3dcompiler_43/reflection.c | 134 +++++++++++++++++++++++++++++++ dlls/d3dcompiler_43/utils.c | 2 + 6 files changed, 141 insertions(+), 144 deletions(-)
diff --git a/dlls/d3d10/Makefile.in b/dlls/d3d10/Makefile.in index dec11188c4d..50807a295a9 100644 --- a/dlls/d3d10/Makefile.in +++ b/dlls/d3d10/Makefile.in @@ -1,13 +1,16 @@ MODULE = d3d10.dll IMPORTLIB = d3d10 -IMPORTS = dxguid uuid d3d10core d3dcompiler dxgi +IMPORTS = uuid d3d10core d3dcompiler dxgi +PARENTSRC = ../d3dcompiler_43
EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \ d3d10_main.c \ effect.c \ + reflection.c \ shader.c \ - stateblock.c + stateblock.c \ + utils.c
RC_SRCS = version.rc diff --git a/dlls/d3d10/d3d10_main.c b/dlls/d3d10/d3d10_main.c index a54c44bdbb9..2d08c82a3c4 100644 --- a/dlls/d3d10/d3d10_main.c +++ b/dlls/d3d10/d3d10_main.c @@ -316,25 +316,3 @@ const char * WINAPI D3D10GetPixelShaderProfile(ID3D10Device *device)
return "ps_4_0"; } - -HRESULT WINAPI D3D10ReflectShader(const void *data, SIZE_T data_size, ID3D10ShaderReflection **reflector) -{ - struct d3d10_shader_reflection *object; - - FIXME("data %p, data_size %lu, reflector %p stub!\n", data, data_size, reflector); - - if (!(object = heap_alloc_zero(sizeof(*object)))) - { - ERR("Failed to allocate D3D10 shader reflection object memory\n"); - return E_OUTOFMEMORY; - } - - object->ID3D10ShaderReflection_iface.lpVtbl = &d3d10_shader_reflection_vtbl; - object->refcount = 1; - - *reflector = &object->ID3D10ShaderReflection_iface; - - TRACE("Created ID3D10ShaderReflection %p\n", object); - - return S_OK; -} diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index fadd027f7a9..96020cd4a0c 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -249,14 +249,6 @@ struct d3d10_effect struct d3d10_effect_technique *techniques; };
-/* ID3D10ShaderReflection */ -extern const struct ID3D10ShaderReflectionVtbl d3d10_shader_reflection_vtbl DECLSPEC_HIDDEN; -struct d3d10_shader_reflection -{ - ID3D10ShaderReflection ID3D10ShaderReflection_iface; - LONG refcount; -}; - HRESULT d3d10_effect_parse(struct d3d10_effect *This, const void *data, SIZE_T data_size) DECLSPEC_HIDDEN;
/* D3D10Core */ diff --git a/dlls/d3d10/shader.c b/dlls/d3d10/shader.c index 52e3cc06bf4..d198689af64 100644 --- a/dlls/d3d10/shader.c +++ b/dlls/d3d10/shader.c @@ -22,118 +22,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
-/* IUnknown methods */ - -static inline struct d3d10_shader_reflection *impl_from_ID3D10ShaderReflection(ID3D10ShaderReflection *iface) -{ - return CONTAINING_RECORD(iface, struct d3d10_shader_reflection, ID3D10ShaderReflection_iface); -} - -static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_QueryInterface(ID3D10ShaderReflection *iface, REFIID riid, void **object) -{ - TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object); - - if (IsEqualGUID(riid, &IID_ID3D10ShaderReflection) - || IsEqualGUID(riid, &IID_IUnknown)) - { - IUnknown_AddRef(iface); - *object = iface; - return S_OK; - } - - WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid)); - - *object = NULL; - return E_NOINTERFACE; -} - -static ULONG STDMETHODCALLTYPE d3d10_shader_reflection_AddRef(ID3D10ShaderReflection *iface) -{ - struct d3d10_shader_reflection *This = impl_from_ID3D10ShaderReflection(iface); - ULONG refcount = InterlockedIncrement(&This->refcount); - - TRACE("%p increasing refcount to %u\n", This, refcount); - - return refcount; -} - -static ULONG STDMETHODCALLTYPE d3d10_shader_reflection_Release(ID3D10ShaderReflection *iface) -{ - struct d3d10_shader_reflection *This = impl_from_ID3D10ShaderReflection(iface); - ULONG refcount = InterlockedDecrement(&This->refcount); - - TRACE("%p decreasing refcount to %u\n", This, refcount); - - if (!refcount) - heap_free(This); - - return refcount; -} - -/* ID3D10ShaderReflection methods */ - -static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetDesc(ID3D10ShaderReflection *iface, D3D10_SHADER_DESC *desc) -{ - FIXME("iface %p, desc %p stub!\n", iface, desc); - - return E_NOTIMPL; -} - -static struct ID3D10ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3d10_shader_reflection_GetConstantBufferByIndex( - ID3D10ShaderReflection *iface, UINT index) -{ - FIXME("iface %p, index %u stub!\n", iface, index); - - return NULL; -} - -static struct ID3D10ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3d10_shader_reflection_GetConstantBufferByName( - ID3D10ShaderReflection *iface, const char *name) -{ - FIXME("iface %p, name %s stub!\n", iface, debugstr_a(name)); - - return NULL; -} - -static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetResourceBindingDesc( - ID3D10ShaderReflection *iface, UINT index, D3D10_SHADER_INPUT_BIND_DESC *desc) -{ - FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc); - - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetInputParameterDesc( - ID3D10ShaderReflection *iface, UINT index, D3D10_SIGNATURE_PARAMETER_DESC *desc) -{ - FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc); - - return E_NOTIMPL; -} - -static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetOutputParameterDesc( - ID3D10ShaderReflection *iface, UINT index, D3D10_SIGNATURE_PARAMETER_DESC *desc) -{ - FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc); - - return E_NOTIMPL; -} - -const struct ID3D10ShaderReflectionVtbl d3d10_shader_reflection_vtbl = -{ - /* IUnknown methods */ - d3d10_shader_reflection_QueryInterface, - d3d10_shader_reflection_AddRef, - d3d10_shader_reflection_Release, - /* ID3D10ShaderReflection methods */ - d3d10_shader_reflection_GetDesc, - d3d10_shader_reflection_GetConstantBufferByIndex, - d3d10_shader_reflection_GetConstantBufferByName, - d3d10_shader_reflection_GetResourceBindingDesc, - d3d10_shader_reflection_GetInputParameterDesc, - d3d10_shader_reflection_GetOutputParameterDesc, -}; - HRESULT WINAPI D3D10CompileShader(const char *data, SIZE_T data_size, const char *filename, const D3D10_SHADER_MACRO *defines, ID3D10Include *include, const char *entrypoint, const char *profile, UINT flags, ID3D10Blob **shader, ID3D10Blob **error_messages) diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c index b163fca9e73..2ea0b46a1c6 100644 --- a/dlls/d3dcompiler_43/reflection.c +++ b/dlls/d3dcompiler_43/reflection.c @@ -21,6 +21,7 @@ #include "initguid.h" #include "d3dcompiler_private.h" #include "winternl.h" +#include "d3d10.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler);
@@ -94,6 +95,7 @@ struct d3dcompiler_shader_reflection_constant_buffer struct d3dcompiler_shader_reflection { ID3D11ShaderReflection ID3D11ShaderReflection_iface; + ID3D10ShaderReflection ID3D10ShaderReflection_iface; LONG refcount;
DWORD target; @@ -1807,6 +1809,138 @@ err_out: return hr; }
+/* d3d10 reflection methods. */ +#ifndef D3D_COMPILER_VERSION +static inline struct d3dcompiler_shader_reflection *impl_from_ID3D10ShaderReflection(ID3D10ShaderReflection *iface) +{ + return CONTAINING_RECORD(iface, struct d3dcompiler_shader_reflection, ID3D10ShaderReflection_iface); +} + +static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_QueryInterface(ID3D10ShaderReflection *iface, + REFIID riid, void **object) +{ + TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object); + + if (IsEqualGUID(riid, &IID_ID3D10ShaderReflection) || IsEqualGUID(riid, &IID_IUnknown)) + { + IUnknown_AddRef(iface); + *object = iface; + return S_OK; + } + + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); + + *object = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE d3d10_shader_reflection_AddRef(ID3D10ShaderReflection *iface) +{ + struct d3dcompiler_shader_reflection *reflection = impl_from_ID3D10ShaderReflection(iface); + ULONG refcount = InterlockedIncrement(&reflection->refcount); + + TRACE("%p increasing refcount to %u.\n", reflection, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE d3d10_shader_reflection_Release(ID3D10ShaderReflection *iface) +{ + struct d3dcompiler_shader_reflection *reflection = impl_from_ID3D10ShaderReflection(iface); + ULONG refcount = InterlockedDecrement(&reflection->refcount); + + TRACE("%p decreasing refcount to %u.\n", reflection, refcount); + + if (!refcount) + heap_free(reflection); + + return refcount; +} + +static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetDesc(ID3D10ShaderReflection *iface, + D3D10_SHADER_DESC *desc) +{ + FIXME("iface %p, desc %p stub!\n", iface, desc); + + return E_NOTIMPL; +} + +static struct ID3D10ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3d10_shader_reflection_GetConstantBufferByIndex( + ID3D10ShaderReflection *iface, UINT index) +{ + FIXME("iface %p, index %u stub!\n", iface, index); + + return NULL; +} + +static struct ID3D10ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3d10_shader_reflection_GetConstantBufferByName( + ID3D10ShaderReflection *iface, const char *name) +{ + FIXME("iface %p, name %s stub!\n", iface, debugstr_a(name)); + + return NULL; +} + +static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetResourceBindingDesc(ID3D10ShaderReflection *iface, + UINT index, D3D10_SHADER_INPUT_BIND_DESC *desc) +{ + FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetInputParameterDesc(ID3D10ShaderReflection *iface, + UINT index, D3D10_SIGNATURE_PARAMETER_DESC *desc) +{ + FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetOutputParameterDesc(ID3D10ShaderReflection *iface, + UINT index, D3D10_SIGNATURE_PARAMETER_DESC *desc) +{ + FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc); + + return E_NOTIMPL; +} + +static const struct ID3D10ShaderReflectionVtbl d3d10_shader_reflection_vtbl = +{ + d3d10_shader_reflection_QueryInterface, + d3d10_shader_reflection_AddRef, + d3d10_shader_reflection_Release, + d3d10_shader_reflection_GetDesc, + d3d10_shader_reflection_GetConstantBufferByIndex, + d3d10_shader_reflection_GetConstantBufferByName, + d3d10_shader_reflection_GetResourceBindingDesc, + d3d10_shader_reflection_GetInputParameterDesc, + d3d10_shader_reflection_GetOutputParameterDesc, +}; + +HRESULT WINAPI D3D10ReflectShader(const void *data, SIZE_T data_size, ID3D10ShaderReflection **reflector) +{ + struct d3dcompiler_shader_reflection *object; + + FIXME("data %p, data_size %lu, reflector %p stub!\n", data, data_size, reflector); + + if (!(object = heap_alloc_zero(sizeof(*object)))) + { + ERR("Failed to allocate D3D10 shader reflection object memory.\n"); + return E_OUTOFMEMORY; + } + + object->ID3D10ShaderReflection_iface.lpVtbl = &d3d10_shader_reflection_vtbl; + object->refcount = 1; + + *reflector = &object->ID3D10ShaderReflection_iface; + + TRACE("Created ID3D10ShaderReflection %p.\n", object); + + return S_OK; +} +#endif + HRESULT WINAPI D3DReflect(const void *data, SIZE_T data_size, REFIID riid, void **reflector) { struct d3dcompiler_shader_reflection *object; diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c index 079bd1c6bc2..27c0ba8c916 100644 --- a/dlls/d3dcompiler_43/utils.c +++ b/dlls/d3dcompiler_43/utils.c @@ -758,6 +758,7 @@ void compilation_message(struct compilation_messages *msg, const char *fmt, __ms } }
+#ifdef D3D_COMPILER_VERSION BOOL add_declaration(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var) { struct hlsl_ir_var *var; @@ -2327,3 +2328,4 @@ void add_function_decl(struct wine_rb_tree *funcs, char *name, struct hlsl_ir_fu func->intrinsic = intrinsic; wine_rb_put(funcs, func->name, &func->entry); } +#endif
From: Connor McAdams conmanx360@gmail.com
Signed-off-by: Connor McAdams conmanx360@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dcompiler_43/reflection.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c index 2ea0b46a1c6..6f982173856 100644 --- a/dlls/d3dcompiler_43/reflection.c +++ b/dlls/d3dcompiler_43/reflection.c @@ -1694,9 +1694,6 @@ static HRESULT d3dcompiler_shader_reflection_init(struct d3dcompiler_shader_refl HRESULT hr; unsigned int i;
- reflection->ID3D11ShaderReflection_iface.lpVtbl = &d3dcompiler_shader_reflection_vtbl; - reflection->refcount = 1; - wine_rb_init(&reflection->types, d3dcompiler_shader_reflection_type_compare);
hr = dxbc_parse(data, data_size, &src_dxbc); @@ -1921,8 +1918,9 @@ static const struct ID3D10ShaderReflectionVtbl d3d10_shader_reflection_vtbl = HRESULT WINAPI D3D10ReflectShader(const void *data, SIZE_T data_size, ID3D10ShaderReflection **reflector) { struct d3dcompiler_shader_reflection *object; + HRESULT hr;
- FIXME("data %p, data_size %lu, reflector %p stub!\n", data, data_size, reflector); + TRACE("data %p, data_size %lu, reflector %p.\n", data, data_size, reflector);
if (!(object = heap_alloc_zero(sizeof(*object)))) { @@ -1933,6 +1931,14 @@ HRESULT WINAPI D3D10ReflectShader(const void *data, SIZE_T data_size, ID3D10Shad object->ID3D10ShaderReflection_iface.lpVtbl = &d3d10_shader_reflection_vtbl; object->refcount = 1;
+ hr = d3dcompiler_shader_reflection_init(object, data, data_size); + if (FAILED(hr)) + { + WARN("Failed to initialize shader reflection.\n"); + HeapFree(GetProcessHeap(), 0, object); + return hr; + } + *reflector = &object->ID3D10ShaderReflection_iface;
TRACE("Created ID3D10ShaderReflection %p.\n", object); @@ -1971,6 +1977,9 @@ HRESULT WINAPI D3DReflect(const void *data, SIZE_T data_size, REFIID riid, void if (!object) return E_OUTOFMEMORY;
+ object->ID3D11ShaderReflection_iface.lpVtbl = &d3dcompiler_shader_reflection_vtbl; + object->refcount = 1; + hr = d3dcompiler_shader_reflection_init(object, data, data_size); if (FAILED(hr)) {
From: Connor McAdams conmanx360@gmail.com
Signed-off-by: Connor McAdams conmanx360@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dcompiler_43/reflection.c | 41 ++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dcompiler_43/reflection.c b/dlls/d3dcompiler_43/reflection.c index 6f982173856..d3d083e8d8c 100644 --- a/dlls/d3dcompiler_43/reflection.c +++ b/dlls/d3dcompiler_43/reflection.c @@ -1857,9 +1857,46 @@ static ULONG STDMETHODCALLTYPE d3d10_shader_reflection_Release(ID3D10ShaderRefle static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetDesc(ID3D10ShaderReflection *iface, D3D10_SHADER_DESC *desc) { - FIXME("iface %p, desc %p stub!\n", iface, desc); + struct d3dcompiler_shader_reflection *reflection = impl_from_ID3D10ShaderReflection(iface);
- return E_NOTIMPL; + FIXME("iface %p, desc %p partial stub!\n", iface, desc); + + if (!desc) + { + WARN("Invalid argument specified.\n"); + return E_FAIL; + } + + desc->Version = reflection->version; + desc->Creator = reflection->creator; + desc->Flags = reflection->flags; + desc->ConstantBuffers = reflection->constant_buffer_count; + desc->BoundResources = reflection->bound_resource_count; + desc->InputParameters = reflection->isgn ? reflection->isgn->element_count : 0; + desc->OutputParameters = reflection->osgn ? reflection->osgn->element_count : 0; + desc->InstructionCount = reflection->instruction_count; + desc->TempRegisterCount = reflection->temp_register_count; + desc->TempArrayCount = reflection->temp_array_count; + desc->DefCount = 0; + desc->DclCount = reflection->dcl_count; + desc->TextureNormalInstructions = reflection->texture_normal_instructions; + desc->TextureLoadInstructions = reflection->texture_load_instructions; + desc->TextureCompInstructions = reflection->texture_comp_instructions; + desc->TextureBiasInstructions = reflection->texture_bias_instructions; + desc->TextureGradientInstructions = reflection->texture_gradient_instructions; + desc->FloatInstructionCount = reflection->float_instruction_count; + desc->IntInstructionCount = reflection->int_instruction_count; + desc->UintInstructionCount = reflection->uint_instruction_count; + desc->StaticFlowControlCount = reflection->static_flow_control_count; + desc->DynamicFlowControlCount = reflection->dynamic_flow_control_count; + desc->MacroInstructionCount = 0; + desc->ArrayInstructionCount = reflection->array_instruction_count; + desc->CutInstructionCount = reflection->cut_instruction_count; + desc->EmitInstructionCount = reflection->emit_instruction_count; + desc->GSOutputTopology = reflection->gs_output_topology; + desc->GSMaxOutputVertexCount = reflection->gs_max_output_vertex_count; + + return S_OK; }
static struct ID3D10ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3d10_shader_reflection_GetConstantBufferByIndex(