Commit 53ea5de6 authored by Rico Schüller's avatar Rico Schüller Committed by Alexandre Julliard

d3d10: Move some helper funcs to utils.

parent bb2600b6
......@@ -218,4 +218,31 @@ HRESULT d3d10_effect_parse(struct d3d10_effect *This, const void *data, SIZE_T d
HRESULT WINAPI D3D10CoreCreateDevice(IDXGIFactory *factory, IDXGIAdapter *adapter,
UINT flags, void *unknown0, ID3D10Device **device);
#define MAKE_TAG(ch0, ch1, ch2, ch3) \
((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \
((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 ))
#define TAG_DXBC MAKE_TAG('D', 'X', 'B', 'C')
#define TAG_FX10 MAKE_TAG('F', 'X', '1', '0')
#define TAG_ISGN MAKE_TAG('I', 'S', 'G', 'N')
#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));
*ptr += sizeof(*d);
}
static inline void write_dword(char **ptr, DWORD d)
{
memcpy(*ptr, &d, sizeof(d));
*ptr += sizeof(d);
}
void skip_dword_unknown(const char **ptr, unsigned int count) DECLSPEC_HIDDEN;
void write_dword_unknown(char **ptr, DWORD d) DECLSPEC_HIDDEN;
#endif /* __WINE_D3D10_PRIVATE_H */
......@@ -25,14 +25,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
#define MAKE_TAG(ch0, ch1, ch2, ch3) \
((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \
((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 ))
#define TAG_DXBC MAKE_TAG('D', 'X', 'B', 'C')
#define TAG_FX10 MAKE_TAG('F', 'X', '1', '0')
#define TAG_ISGN MAKE_TAG('I', 'S', 'G', 'N')
#define TAG_OSGN MAKE_TAG('O', 'S', 'G', 'N')
#define D3D10_FX10_TYPE_COLUMN_SHIFT 11
#define D3D10_FX10_TYPE_COLUMN_MASK (0x7 << D3D10_FX10_TYPE_COLUMN_SHIFT)
......@@ -118,88 +110,6 @@ static struct d3d10_effect_variable anonymous_gs = {(const ID3D10EffectVariableV
static struct d3d10_effect_type *get_fx10_type(struct d3d10_effect *effect, const char *data, DWORD offset);
static inline void read_dword(const char **ptr, DWORD *d)
{
memcpy(d, *ptr, sizeof(*d));
*ptr += sizeof(*d);
}
static inline void skip_dword_unknown(const char **ptr, unsigned int count)
{
unsigned int i;
DWORD d;
FIXME("Skipping %u unknown DWORDs:\n", count);
for (i = 0; i < count; ++i)
{
read_dword(ptr, &d);
FIXME("\t0x%08x\n", d);
}
}
static inline void write_dword(char **ptr, DWORD d)
{
memcpy(*ptr, &d, sizeof(d));
*ptr += sizeof(d);
}
static inline 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 tag;
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(&ptr, 4);
skip_dword_unknown(&ptr, 1);
read_dword(&ptr, &total_size);
TRACE("total size: %#x\n", total_size);
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);
chunk_ptr = data + chunk_offset;
read_dword(&chunk_ptr, &chunk_tag);
read_dword(&chunk_ptr, &chunk_size);
hr = chunk_handler(chunk_ptr, chunk_size, chunk_tag, ctx);
if (FAILED(hr)) break;
}
return hr;
}
static BOOL copy_name(const char *ptr, char **name)
{
size_t name_len;
......
......@@ -111,3 +111,73 @@ void d3d10_rb_free(void *ptr)
{
HeapFree(GetProcessHeap(), 0, ptr);
}
void skip_dword_unknown(const char **ptr, unsigned int count)
{
unsigned int i;
DWORD d;
FIXME("Skipping %u unknown DWORDs:\n", count);
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 tag;
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(&ptr, 4);
skip_dword_unknown(&ptr, 1);
read_dword(&ptr, &total_size);
TRACE("total size: %#x\n", total_size);
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);
chunk_ptr = data + chunk_offset;
read_dword(&chunk_ptr, &chunk_tag);
read_dword(&chunk_ptr, &chunk_size);
hr = chunk_handler(chunk_ptr, chunk_size, chunk_tag, ctx);
if (FAILED(hr)) break;
}
return hr;
}
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