Commit bb3b5a73 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d10core: Parse pixelshader output signatures and pass them to CreatePixelShader().

parent d6fa27f5
......@@ -39,8 +39,15 @@
((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 ))
#define TAG_DXBC MAKE_TAG('D', 'X', 'B', 'C')
#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')
struct d3d10_shader_info
{
const DWORD *shader_code;
struct wined3d_shader_signature *output_signature;
};
/* TRACE helper functions */
const char *debug_d3d10_primitive_topology(D3D10_PRIMITIVE_TOPOLOGY topology);
const char *debug_dxgi_format(DXGI_FORMAT format);
......@@ -152,9 +159,10 @@ struct d3d10_pixel_shader
LONG refcount;
IWineD3DPixelShader *wined3d_shader;
struct wined3d_shader_signature output_signature;
};
HRESULT shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length, const DWORD **shader_code);
HRESULT shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length, struct d3d10_shader_info *shader_info);
HRESULT shader_parse_signature(const char *data, DWORD data_size, struct wined3d_shader_signature *s);
void shader_free_signature(struct wined3d_shader_signature *s);
......
......@@ -1025,19 +1025,12 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device *if
{
struct d3d10_device *This = (struct d3d10_device *)iface;
struct d3d10_pixel_shader *object;
const DWORD *shader_code;
struct d3d10_shader_info shader_info;
HRESULT hr;
TRACE("iface %p, byte_code %p, byte_code_length %lu, shader %p\n",
iface, byte_code, byte_code_length, shader);
hr = shader_extract_from_dxbc(byte_code, byte_code_length, &shader_code);
if (FAILED(hr))
{
ERR("Failed to extract shader, hr %#x\n", hr);
return hr;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
{
......@@ -1048,11 +1041,22 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreatePixelShader(ID3D10Device *if
object->vtbl = &d3d10_pixel_shader_vtbl;
object->refcount = 1;
shader_info.output_signature = &object->output_signature;
hr = shader_extract_from_dxbc(byte_code, byte_code_length, &shader_info);
if (FAILED(hr))
{
ERR("Failed to extract shader, hr %#x\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
hr = IWineD3DDevice_CreatePixelShader(This->wined3d_device,
shader_code, NULL, &object->wined3d_shader, (IUnknown *)object);
shader_info.shader_code, &object->output_signature,
&object->wined3d_shader, (IUnknown *)object);
if (FAILED(hr))
{
ERR("CreatePixelShader failed, hr %#x\n", hr);
shader_free_signature(&object->output_signature);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
......
......@@ -26,31 +26,46 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
static HRESULT shdr_handler(const char *data, DWORD data_size, DWORD tag, void *ctx)
{
const DWORD **shader_data = ctx;
struct d3d10_shader_info *shader_info = ctx;
char tag_str[5];
HRESULT hr;
switch(tag)
{
case TAG_OSGN:
hr = shader_parse_signature(data, data_size, shader_info->output_signature);
if (FAILED(hr)) return hr;
break;
case TAG_SHDR:
*shader_data = (const DWORD *)data;
return S_OK;
shader_info->shader_code = (const DWORD *)data;
break;
default:
memcpy(tag_str, &tag, 4);
tag_str[4] = '\0';
FIXME("Unhandled chunk %s\n", tag_str);
return S_OK;
break;
}
return S_OK;
}
HRESULT shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length, const DWORD **shader_code)
HRESULT shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length, struct d3d10_shader_info *shader_info)
{
HRESULT hr;
hr = parse_dxbc(dxbc, dxbc_length, shdr_handler, shader_code);
if (!*shader_code) hr = E_FAIL;
shader_info->shader_code = NULL;
memset(shader_info->output_signature, 0, sizeof(*shader_info->output_signature));
if (FAILED(hr)) ERR("Failed to parse shader, hr %#x\n", hr);
hr = parse_dxbc(dxbc, dxbc_length, shdr_handler, shader_info);
if (!shader_info->shader_code) hr = E_FAIL;
if (FAILED(hr))
{
ERR("Failed to parse shader, hr %#x\n", hr);
shader_free_signature(shader_info->output_signature);
}
return hr;
}
......@@ -347,6 +362,7 @@ static ULONG STDMETHODCALLTYPE d3d10_pixel_shader_Release(ID3D10PixelShader *ifa
if (!refcount)
{
shader_free_signature(&This->output_signature);
HeapFree(GetProcessHeap(), 0, This);
}
......
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