Commit 2c9b24b0 authored by Rico Schüller's avatar Rico Schüller Committed by Alexandre Julliard

d3dcompiler: Implement D3DStripShader().

parent a36f51b1
...@@ -285,3 +285,92 @@ HRESULT d3dcompiler_get_blob_part(const void *data, SIZE_T data_size, D3D_BLOB_P ...@@ -285,3 +285,92 @@ HRESULT d3dcompiler_get_blob_part(const void *data, SIZE_T data_size, D3D_BLOB_P
return hr; return hr;
} }
static BOOL check_blob_strip(DWORD tag, UINT flags)
{
BOOL add = TRUE;
if (flags & D3DCOMPILER_STRIP_TEST_BLOBS) FIXME("Unhandled flag D3DCOMPILER_STRIP_TEST_BLOBS.\n");
switch(tag)
{
case TAG_RDEF:
case TAG_STAT:
if (flags & D3DCOMPILER_STRIP_REFLECTION_DATA) add = FALSE;
break;
case TAG_SDBG:
if (flags & D3DCOMPILER_STRIP_DEBUG_INFO) add = FALSE;
break;
default:
break;
}
TRACE("%s tag %s\n", add ? "Add" : "Skip", debugstr_an((const char *)&tag, 4));
return add;
}
HRESULT d3dcompiler_strip_shader(const void *data, SIZE_T data_size, UINT flags, ID3DBlob **blob)
{
struct dxbc src_dxbc, dst_dxbc;
HRESULT hr;
unsigned int i;
if (!blob)
{
WARN("NULL for blob specified\n");
return E_FAIL;
}
if (!data || !data_size)
{
WARN("Invalid arguments: data %p, data_size %lu\n", data, data_size);
return D3DERR_INVALIDCALL;
}
hr = dxbc_parse(data, data_size, &src_dxbc);
if (FAILED(hr))
{
WARN("Failed to parse blob part\n");
return hr;
}
/* src_dxbc.count >= dst_dxbc.count */
hr = dxbc_init(&dst_dxbc, src_dxbc.count);
if (FAILED(hr))
{
dxbc_destroy(&src_dxbc);
WARN("Failed to init dxbc\n");
return hr;
}
for (i = 0; i < src_dxbc.count; ++i)
{
struct dxbc_section *section = &src_dxbc.sections[i];
if (check_blob_strip(section->tag, flags))
{
hr = dxbc_add_section(&dst_dxbc, section->tag, section->data, section->data_size);
if (FAILED(hr))
{
dxbc_destroy(&src_dxbc);
dxbc_destroy(&dst_dxbc);
WARN("Failed to add section to dxbc\n");
return hr;
}
}
}
hr = dxbc_write_blob(&dst_dxbc, blob);
if (FAILED(hr))
{
WARN("Failed to write blob part\n");
}
dxbc_destroy(&src_dxbc);
dxbc_destroy(&dst_dxbc);
return hr;
}
...@@ -14,4 +14,4 @@ ...@@ -14,4 +14,4 @@
@ stdcall D3DPreprocess(ptr long str ptr ptr ptr ptr) @ stdcall D3DPreprocess(ptr long str ptr ptr ptr ptr)
@ stub D3DReflect @ stub D3DReflect
@ stub D3DReturnFailure1 @ stub D3DReturnFailure1
@ stub D3DStripShader @ stdcall D3DStripShader(ptr long long ptr)
...@@ -116,3 +116,10 @@ HRESULT WINAPI D3DGetDebugInfo(const void *data, SIZE_T data_size, ID3DBlob **bl ...@@ -116,3 +116,10 @@ HRESULT WINAPI D3DGetDebugInfo(const void *data, SIZE_T data_size, ID3DBlob **bl
return d3dcompiler_get_blob_part(data, data_size, D3D_BLOB_DEBUG_INFO, 0, blob); return d3dcompiler_get_blob_part(data, data_size, D3D_BLOB_DEBUG_INFO, 0, blob);
} }
HRESULT WINAPI D3DStripShader(const void *data, SIZE_T data_size, UINT flags, ID3D10Blob **blob)
{
TRACE("data %p, data_size %lu, flags %#x, blob %p\n", data, data_size, flags, blob);
return d3dcompiler_strip_shader(data, data_size, flags, blob);
}
...@@ -55,6 +55,7 @@ HRESULT d3dcompiler_blob_init(struct d3dcompiler_blob *blob, SIZE_T data_size) D ...@@ -55,6 +55,7 @@ HRESULT d3dcompiler_blob_init(struct d3dcompiler_blob *blob, SIZE_T data_size) D
/* blob handling */ /* blob handling */
HRESULT d3dcompiler_get_blob_part(const void *data, SIZE_T data_size, D3D_BLOB_PART part, UINT flags, ID3DBlob **blob) DECLSPEC_HIDDEN; HRESULT d3dcompiler_get_blob_part(const void *data, SIZE_T data_size, D3D_BLOB_PART part, UINT flags, ID3DBlob **blob) DECLSPEC_HIDDEN;
HRESULT d3dcompiler_strip_shader(const void *data, SIZE_T data_size, UINT flags, ID3DBlob **blob) DECLSPEC_HIDDEN;
/* Shader assembler definitions */ /* Shader assembler definitions */
typedef enum _shader_type { typedef enum _shader_type {
...@@ -585,7 +586,9 @@ void SlDeleteShader(struct bwriter_shader *shader); ...@@ -585,7 +586,9 @@ void SlDeleteShader(struct bwriter_shader *shader);
#define TAG_ISGN MAKE_TAG('I', 'S', 'G', 'N') #define TAG_ISGN MAKE_TAG('I', 'S', 'G', 'N')
#define TAG_OSGN MAKE_TAG('O', 'S', 'G', 'N') #define TAG_OSGN MAKE_TAG('O', 'S', 'G', 'N')
#define TAG_PCSG MAKE_TAG('P', 'C', 'S', 'G') #define TAG_PCSG MAKE_TAG('P', 'C', 'S', 'G')
#define TAG_RDEF MAKE_TAG('R', 'D', 'E', 'F')
#define TAG_SDBG MAKE_TAG('S', 'D', 'B', 'G') #define TAG_SDBG MAKE_TAG('S', 'D', 'B', 'G')
#define TAG_STAT MAKE_TAG('S', 'T', 'A', 'T')
#define TAG_XNAP MAKE_TAG('X', 'N', 'A', 'P') #define TAG_XNAP MAKE_TAG('X', 'N', 'A', 'P')
#define TAG_XNAS MAKE_TAG('X', 'N', 'A', 'S') #define TAG_XNAS MAKE_TAG('X', 'N', 'A', 'S')
......
...@@ -45,6 +45,16 @@ HRESULT WINAPI D3DCompile(const void *data, SIZE_T data_size, const char *filena ...@@ -45,6 +45,16 @@ HRESULT WINAPI D3DCompile(const void *data, SIZE_T data_size, const char *filena
const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint, const D3D_SHADER_MACRO *defines, ID3DInclude *include, const char *entrypoint,
const char *target, UINT sflags, UINT eflags, ID3DBlob **shader, ID3DBlob **error_messages); const char *target, UINT sflags, UINT eflags, ID3DBlob **shader, ID3DBlob **error_messages);
typedef enum D3DCOMPILER_STRIP_FLAGS
{
D3DCOMPILER_STRIP_REFLECTION_DATA = 1,
D3DCOMPILER_STRIP_DEBUG_INFO = 2,
D3DCOMPILER_STRIP_TEST_BLOBS = 4,
D3DCOMPILER_STRIP_FORCE_DWORD = 0x7fffffff
} D3DCOMPILER_STRIP_FLAGS;
HRESULT WINAPI D3DStripShader(const void *data, SIZE_T data_size, UINT flags, ID3DBlob **blob);
typedef enum D3D_BLOB_PART typedef enum D3D_BLOB_PART
{ {
D3D_BLOB_INPUT_SIGNATURE_BLOB, D3D_BLOB_INPUT_SIGNATURE_BLOB,
......
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