diff --git a/dlls/d3dcompiler_43/blob.c b/dlls/d3dcompiler_43/blob.c index b22a3c64365..d6740905ff2 100644 --- a/dlls/d3dcompiler_43/blob.c +++ b/dlls/d3dcompiler_43/blob.c @@ -119,10 +119,31 @@ HRESULT d3dcompiler_blob_init(struct d3dcompiler_blob *blob, SIZE_T data_size) return S_OK; } +static BOOL check_blob_part(DWORD tag, D3D_BLOB_PART part) +{ + BOOL add = FALSE; + + switch(part) + { + case D3D_BLOB_INPUT_SIGNATURE_BLOB: + if (tag == TAG_ISGN) add = TRUE; + break; + + default: + FIXME("Unhandled D3D_BLOB_PART %s.\n", debug_d3dcompiler_d3d_blob_part(part)); + break; + } + + TRACE("%s tag %s\n", add ? "Add" : "Skip", debugstr_an((const char *)&tag, 4)); + + return add; +} + HRESULT d3dcompiler_get_blob_part(const void *data, SIZE_T data_size, D3D_BLOB_PART part, UINT flags, ID3DBlob **blob) { struct dxbc src_dxbc, dst_dxbc; HRESULT hr; + unsigned int i, count; if (!data || !data_size || flags || !blob) { @@ -144,6 +165,52 @@ HRESULT d3dcompiler_get_blob_part(const void *data, SIZE_T data_size, D3D_BLOB_P return hr; } + hr = dxbc_init(&dst_dxbc, 0); + 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_part(section->tag, part)) + { + 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; + } + } + } + + count = dst_dxbc.count; + + switch(part) + { + case D3D_BLOB_INPUT_SIGNATURE_BLOB: + if (count != 1) count = 0; + break; + + default: + FIXME("Unhandled D3D_BLOB_PART %s.\n", debug_d3dcompiler_d3d_blob_part(part)); + break; + } + + if (count == 0) + { + dxbc_destroy(&src_dxbc); + dxbc_destroy(&dst_dxbc); + WARN("Nothing to write into the blob (count = 0)\n"); + return E_FAIL; + } + hr = dxbc_write_blob(&dst_dxbc, blob); if (FAILED(hr)) { diff --git a/dlls/d3dcompiler_43/d3dcompiler_43.spec b/dlls/d3dcompiler_43/d3dcompiler_43.spec index a54ddfb9e98..41f104981b1 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_43.spec +++ b/dlls/d3dcompiler_43/d3dcompiler_43.spec @@ -9,7 +9,7 @@ @ stdcall D3DGetBlobPart(ptr long long long ptr) @ stub D3DGetDebugInfo @ stub D3DGetInputAndOutputSignatureBlob -@ stub D3DGetInputSignatureBlob +@ stdcall D3DGetInputSignatureBlob(ptr long ptr) @ stub D3DGetOutputSignatureBlob @ stdcall D3DPreprocess(ptr long str ptr ptr ptr ptr) @ stub D3DReflect diff --git a/dlls/d3dcompiler_43/d3dcompiler_43_main.c b/dlls/d3dcompiler_43/d3dcompiler_43_main.c index 59438424b5d..88af168a98d 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_43_main.c +++ b/dlls/d3dcompiler_43/d3dcompiler_43_main.c @@ -88,3 +88,10 @@ HRESULT WINAPI D3DGetBlobPart(const void *data, SIZE_T data_size, D3D_BLOB_PART return d3dcompiler_get_blob_part(data, data_size, part, flags, blob); } + +HRESULT WINAPI D3DGetInputSignatureBlob(const void *data, SIZE_T data_size, ID3DBlob **blob) +{ + TRACE("data %p, data_size %lu, blob %p\n", data, data_size, blob); + + return d3dcompiler_get_blob_part(data, data_size, D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, blob); +} diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h index 5787ab23909..eb7674fe4b3 100644 --- a/dlls/d3dcompiler_43/d3dcompiler_private.h +++ b/dlls/d3dcompiler_43/d3dcompiler_private.h @@ -581,6 +581,7 @@ void SlDeleteShader(struct bwriter_shader *shader); ((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \ ((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 )) #define TAG_DXBC MAKE_TAG('D', 'X', 'B', 'C') +#define TAG_ISGN MAKE_TAG('I', 'S', 'G', 'N') struct dxbc_section { diff --git a/include/d3dcompiler.h b/include/d3dcompiler.h index 6e039b5bc30..0dfe9ff65ab 100644 --- a/include/d3dcompiler.h +++ b/include/d3dcompiler.h @@ -62,6 +62,7 @@ typedef enum D3D_BLOB_PART } D3D_BLOB_PART; HRESULT WINAPI D3DGetBlobPart(const void *data, SIZE_T data_size, D3D_BLOB_PART part, UINT flags, ID3DBlob **blob); +HRESULT WINAPI D3DGetInputSignatureBlob(const void *data, SIZE_T data_size, ID3DBlob **blob); HRESULT WINAPI D3DCreateBlob(SIZE_T data_size, ID3DBlob **blob);