[PATCH] d3dx9_36: Filter out D3DCompile warning messages that are not present with D3DCompileShader.
Christian Costa
titan.costa at gmail.com
Wed Jul 31 02:10:58 CDT 2013
This patch fixes vertex processing issue of bug 33770.
The problem comes from the fact that even if the call succeeds,
the game interprets a non null error_messages pointer as an error.
By calling D3DCompile we use a newer version of the compiler which is more
strict and generates the following warning.
- warning X3206: 'dot': implicit truncation of vector type
- warning X3206: implicit truncation of vector type
- warning X3206: 'mul': implicit truncation of vector type
D3DCompileShader does not generate such warnings.
These is confirmed in the DX SDK release note:
New Warning X3206: Implicit Truncation of Vector Type
Beginning in the August 2009 release of the DirectX SDK, the compiler will warn
when an implicit truncation of a vector type occurs.
The warnings cannot be disable so this patch filters out these strings in D3DCompileShader
and reset the error messages pointer if the resulting buffer is empty.
---
dlls/d3dx9_36/shader.c | 53 ++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 49 insertions(+), 4 deletions(-)
diff --git a/dlls/d3dx9_36/shader.c b/dlls/d3dx9_36/shader.c
index 16395e8..c7ff6e6 100644
--- a/dlls/d3dx9_36/shader.c
+++ b/dlls/d3dx9_36/shader.c
@@ -367,14 +367,59 @@ HRESULT WINAPI D3DXCompileShader(const char *data, UINT length, const D3DXMACRO
hr = D3DCompile(data, length, NULL, (D3D_SHADER_MACRO *)defines, (ID3DInclude *)include,
function, profile, flags, 0, (ID3DBlob **)shader, (ID3DBlob **)error_msgs);
- if (SUCCEEDED(hr) && constant_table)
+ /* Filter out D3DCompile warning messages that are not present with D3DCompileShader */
+ if (SUCCEEDED(hr) && *error_msgs)
{
- hr = D3DXGetShaderConstantTable(ID3DXBuffer_GetBufferPointer(*shader), constant_table);
- if (FAILED(hr))
+ char *in, *line_in, *msgs_in, *line_out, *msgs_out;
+ DWORD size;
+ BOOL end = FALSE;
+
+ in = line_in = msgs_in = ID3DXBuffer_GetBufferPointer(*error_msgs);
+ size = ID3DXBuffer_GetBufferSize(*error_msgs);
+ line_out = msgs_out = HeapAlloc(GetProcessHeap(), 0, size+1); /* +1 byte in case null byte is missing from input string */
+
+ if (!msgs_out)
{
ID3DXBuffer_Release(*shader);
- *shader = NULL;
+ ID3DXBuffer_Release(*error_msgs);
+ return E_OUTOFMEMORY;
+ }
+
+ while (!end)
+ {
+ end = (in == (msgs_in + size)) || !*in;
+ if (end || (*in++ == 0x0a))
+ {
+ int line_size = in - line_in;
+ memcpy(line_out, line_in, line_size);
+ line_out[line_size] = 0;
+ line_in += line_size;
+ if (!(strstr(line_out, "warning X3206:") && strstr(line_out, "implicit truncation of vector type")))
+ line_out += line_size;
+ }
+ }
+
+ ID3DXBuffer_Release(*error_msgs);
+ /* Only return a buffer if the resulting string is not empty as some apps depend on that */
+ if (*msgs_out)
+ {
+ hr = D3DXCreateBuffer(strlen(msgs_out)+1, error_msgs);
+ if (SUCCEEDED(hr))
+ strcpy(ID3DXBuffer_GetBufferPointer(*error_msgs), msgs_out);
+ }
+ else
+ {
+ *error_msgs = NULL;
}
+ HeapFree(GetProcessHeap(), 0, msgs_out);
+ }
+ if (SUCCEEDED(hr) && constant_table)
+ hr = D3DXGetShaderConstantTable(ID3DXBuffer_GetBufferPointer(*shader), constant_table);
+
+ if (FAILED(hr) && shader && *shader)
+ {
+ ID3DXBuffer_Release(*shader);
+ *shader = NULL;
}
return hr;
More information about the wine-patches
mailing list