parse_dxbc is only used in effects.c, so having it in utils.c isn't necessary.
Signed-off-by: Connor McAdams conmanx360@gmail.com --- dlls/d3d10/d3d10_private.h | 6 --- dlls/d3d10/effect.c | 101 +++++++++++++++++++++++++++++++++++++ dlls/d3d10/utils.c | 101 ------------------------------------- 3 files changed, 101 insertions(+), 107 deletions(-)
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index f3fce9c569..2fe6183e15 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -278,9 +278,6 @@ HRESULT WINAPI D3D10CoreCreateDevice(IDXGIFactory *factory, IDXGIAdapter *adapte #define TAG_OSGN MAKE_TAG('O', 'S', 'G', 'N') #define TAG_SHDR MAKE_TAG('S', 'H', 'D', 'R')
-HRESULT parse_dxbc(const char *data, SIZE_T data_size, - HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx) DECLSPEC_HIDDEN; - static inline void read_dword(const char **ptr, DWORD *d) { memcpy(d, *ptr, sizeof(*d)); @@ -298,7 +295,4 @@ static inline BOOL require_space(size_t offset, size_t count, size_t size, size_ return !count || (data_size - offset) / count >= size; }
-void skip_dword_unknown(const char *location, const char **ptr, unsigned int count) DECLSPEC_HIDDEN; -void write_dword_unknown(char **ptr, DWORD d) DECLSPEC_HIDDEN; - #endif /* __WINE_D3D10_PRIVATE_H */ diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 439833485d..ba5b033b0c 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -241,6 +241,107 @@ static const struct d3d10_effect_state_storage_info d3d10_effect_state_storage_i {D3D10_SVT_SAMPLER, sizeof(default_sampler_desc), &default_sampler_desc }, };
+static void skip_dword_unknown(const char *location, const char **ptr, unsigned int count) +{ + unsigned int i; + DWORD d; + + FIXME("Skipping %u unknown DWORDs (%s):\n", count, location); + for (i = 0; i < count; ++i) + { + read_dword(ptr, &d); + FIXME("\t0x%08x\n", d); + } +} + +static void write_dword_unknown(char **ptr, DWORD d) +{ + FIXME("Writing unknown DWORD 0x%08x\n", d); + write_dword(ptr, d); +} + +static HRESULT parse_dxbc(const char *data, SIZE_T data_size, + HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx) +{ + const char *ptr = data; + HRESULT hr = S_OK; + DWORD chunk_count; + DWORD total_size; + unsigned int i; + DWORD version; + DWORD tag; + + if (!data) + { + WARN("No data supplied.\n"); + return E_FAIL; + } + + read_dword(&ptr, &tag); + TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4)); + + if (tag != TAG_DXBC) + { + WARN("Wrong tag.\n"); + return E_FAIL; + } + + /* checksum? */ + skip_dword_unknown("DXBC header", &ptr, 4); + + read_dword(&ptr, &version); + TRACE("version: %#x.\n", version); + if (version != 0x00000001) + { + WARN("Got unexpected DXBC version %#x.\n", version); + return E_FAIL; + } + + read_dword(&ptr, &total_size); + TRACE("total size: %#x\n", total_size); + + if (data_size != total_size) + { + WARN("Wrong size supplied.\n"); + return E_FAIL; + } + + read_dword(&ptr, &chunk_count); + TRACE("chunk count: %#x\n", chunk_count); + + for (i = 0; i < chunk_count; ++i) + { + DWORD chunk_tag, chunk_size; + const char *chunk_ptr; + DWORD chunk_offset; + + read_dword(&ptr, &chunk_offset); + TRACE("chunk %u at offset %#x\n", i, chunk_offset); + + if (chunk_offset >= data_size || !require_space(chunk_offset, 2, sizeof(DWORD), data_size)) + { + WARN("Invalid chunk offset %#x (data size %#lx).\n", chunk_offset, data_size); + return E_FAIL; + } + + chunk_ptr = data + chunk_offset; + + read_dword(&chunk_ptr, &chunk_tag); + read_dword(&chunk_ptr, &chunk_size); + + if (!require_space(chunk_ptr - data, 1, chunk_size, data_size)) + { + WARN("Invalid chunk size %#x (data size %#lx, chunk offset %#x).\n", chunk_size, data_size, chunk_offset); + return E_FAIL; + } + + hr = chunk_handler(chunk_ptr, chunk_size, chunk_tag, ctx); + if (FAILED(hr)) break; + } + + return hr; +} + static BOOL fx10_get_string(const char *data, size_t data_size, DWORD offset, const char **s, size_t *l) { size_t len, max_len; diff --git a/dlls/d3d10/utils.c b/dlls/d3d10/utils.c index 3b51868488..9c76e1f375 100644 --- a/dlls/d3d10/utils.c +++ b/dlls/d3d10/utils.c @@ -128,104 +128,3 @@ const char *debug_d3d10_device_state_types(D3D10_DEVICE_STATE_TYPES t) }
#undef WINE_D3D10_TO_STR - -void skip_dword_unknown(const char *location, const char **ptr, unsigned int count) -{ - unsigned int i; - DWORD d; - - FIXME("Skipping %u unknown DWORDs (%s):\n", count, location); - for (i = 0; i < count; ++i) - { - read_dword(ptr, &d); - FIXME("\t0x%08x\n", d); - } -} - -void write_dword_unknown(char **ptr, DWORD d) -{ - FIXME("Writing unknown DWORD 0x%08x\n", d); - write_dword(ptr, d); -} - -HRESULT parse_dxbc(const char *data, SIZE_T data_size, - HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx) -{ - const char *ptr = data; - HRESULT hr = S_OK; - DWORD chunk_count; - DWORD total_size; - unsigned int i; - DWORD version; - DWORD tag; - - if (!data) - { - WARN("No data supplied.\n"); - return E_FAIL; - } - - read_dword(&ptr, &tag); - TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4)); - - if (tag != TAG_DXBC) - { - WARN("Wrong tag.\n"); - return E_FAIL; - } - - /* checksum? */ - skip_dword_unknown("DXBC header", &ptr, 4); - - read_dword(&ptr, &version); - TRACE("version: %#x.\n", version); - if (version != 0x00000001) - { - WARN("Got unexpected DXBC version %#x.\n", version); - return E_FAIL; - } - - read_dword(&ptr, &total_size); - TRACE("total size: %#x\n", total_size); - - if (data_size != total_size) - { - WARN("Wrong size supplied.\n"); - return E_FAIL; - } - - read_dword(&ptr, &chunk_count); - TRACE("chunk count: %#x\n", chunk_count); - - for (i = 0; i < chunk_count; ++i) - { - DWORD chunk_tag, chunk_size; - const char *chunk_ptr; - DWORD chunk_offset; - - read_dword(&ptr, &chunk_offset); - TRACE("chunk %u at offset %#x\n", i, chunk_offset); - - if (chunk_offset >= data_size || !require_space(chunk_offset, 2, sizeof(DWORD), data_size)) - { - WARN("Invalid chunk offset %#x (data size %#lx).\n", chunk_offset, data_size); - return E_FAIL; - } - - chunk_ptr = data + chunk_offset; - - read_dword(&chunk_ptr, &chunk_tag); - read_dword(&chunk_ptr, &chunk_size); - - if (!require_space(chunk_ptr - data, 1, chunk_size, data_size)) - { - WARN("Invalid chunk size %#x (data size %#lx, chunk offset %#x).\n", chunk_size, data_size, chunk_offset); - return E_FAIL; - } - - hr = chunk_handler(chunk_ptr, chunk_size, chunk_tag, ctx); - if (FAILED(hr)) break; - } - - return hr; -}