Commit 875a7c54 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Use the input signature to setup SM4 pixel shader input semantics.

parent a21784b1
......@@ -50,6 +50,7 @@ struct d3d10_device;
struct d3d10_shader_info
{
const DWORD *shader_code;
struct wined3d_shader_signature *input_signature;
struct wined3d_shader_signature *output_signature;
};
......
......@@ -29,11 +29,16 @@ static HRESULT shdr_handler(const char *data, DWORD data_size, DWORD tag, void *
struct d3d10_shader_info *shader_info = ctx;
HRESULT hr;
switch(tag)
switch (tag)
{
case TAG_ISGN:
if (FAILED(hr = shader_parse_signature(data, data_size, shader_info->input_signature)))
return hr;
break;
case TAG_OSGN:
hr = shader_parse_signature(data, data_size, shader_info->output_signature);
if (FAILED(hr)) return hr;
if (FAILED(hr = shader_parse_signature(data, data_size, shader_info->output_signature)))
return hr;
break;
case TAG_SHDR:
......@@ -53,6 +58,7 @@ static HRESULT shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length, st
HRESULT hr;
shader_info->shader_code = NULL;
memset(shader_info->input_signature, 0, sizeof(*shader_info->input_signature));
memset(shader_info->output_signature, 0, sizeof(*shader_info->output_signature));
hr = parse_dxbc(dxbc, dxbc_length, shdr_handler, shader_info);
......@@ -61,6 +67,7 @@ static HRESULT shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length, st
if (FAILED(hr))
{
ERR("Failed to parse shader, hr %#x\n", hr);
shader_free_signature(shader_info->input_signature);
shader_free_signature(shader_info->output_signature);
}
......@@ -243,22 +250,30 @@ HRESULT d3d10_vertex_shader_init(struct d3d10_vertex_shader *shader, struct d3d1
const void *byte_code, SIZE_T byte_code_length)
{
struct wined3d_shader_signature output_signature;
struct wined3d_shader_signature input_signature;
struct d3d10_shader_info shader_info;
struct wined3d_shader_desc desc;
HRESULT hr;
shader->ID3D10VertexShader_iface.lpVtbl = &d3d10_vertex_shader_vtbl;
shader->refcount = 1;
shader_info.input_signature = &input_signature;
shader_info.output_signature = &output_signature;
hr = shader_extract_from_dxbc(byte_code, byte_code_length, &shader_info);
if (FAILED(hr))
if (FAILED(hr = shader_extract_from_dxbc(byte_code, byte_code_length, &shader_info)))
{
ERR("Failed to extract shader, hr %#x.\n", hr);
return hr;
}
hr = wined3d_shader_create_vs(device->wined3d_device, shader_info.shader_code,
&output_signature, shader, &d3d10_vertex_shader_wined3d_parent_ops, &shader->wined3d_shader, 4);
desc.byte_code = shader_info.shader_code;
desc.input_signature = &input_signature;
desc.output_signature = &output_signature;
desc.max_version = 4;
hr = wined3d_shader_create_vs(device->wined3d_device, &desc, shader,
&d3d10_vertex_shader_wined3d_parent_ops, &shader->wined3d_shader);
shader_free_signature(&input_signature);
shader_free_signature(&output_signature);
if (FAILED(hr))
{
......@@ -391,22 +406,30 @@ HRESULT d3d10_geometry_shader_init(struct d3d10_geometry_shader *shader, struct
const void *byte_code, SIZE_T byte_code_length)
{
struct wined3d_shader_signature output_signature;
struct wined3d_shader_signature input_signature;
struct d3d10_shader_info shader_info;
struct wined3d_shader_desc desc;
HRESULT hr;
shader->ID3D10GeometryShader_iface.lpVtbl = &d3d10_geometry_shader_vtbl;
shader->refcount = 1;
shader_info.input_signature = &input_signature;
shader_info.output_signature = &output_signature;
hr = shader_extract_from_dxbc(byte_code, byte_code_length, &shader_info);
if (FAILED(hr))
if (FAILED(hr = shader_extract_from_dxbc(byte_code, byte_code_length, &shader_info)))
{
ERR("Failed to extract shader, hr %#x.\n", hr);
return hr;
}
hr = wined3d_shader_create_gs(device->wined3d_device, shader_info.shader_code,
&output_signature, shader, &d3d10_geometry_shader_wined3d_parent_ops, &shader->wined3d_shader, 4);
desc.byte_code = shader_info.shader_code;
desc.input_signature = &input_signature;
desc.output_signature = &output_signature;
desc.max_version = 4;
hr = wined3d_shader_create_gs(device->wined3d_device, &desc, shader,
&d3d10_geometry_shader_wined3d_parent_ops, &shader->wined3d_shader);
shader_free_signature(&input_signature);
shader_free_signature(&output_signature);
if (FAILED(hr))
{
......@@ -554,22 +577,30 @@ HRESULT d3d10_pixel_shader_init(struct d3d10_pixel_shader *shader, struct d3d10_
const void *byte_code, SIZE_T byte_code_length)
{
struct wined3d_shader_signature output_signature;
struct wined3d_shader_signature input_signature;
struct d3d10_shader_info shader_info;
struct wined3d_shader_desc desc;
HRESULT hr;
shader->ID3D10PixelShader_iface.lpVtbl = &d3d10_pixel_shader_vtbl;
shader->refcount = 1;
shader_info.input_signature = &input_signature;
shader_info.output_signature = &output_signature;
hr = shader_extract_from_dxbc(byte_code, byte_code_length, &shader_info);
if (FAILED(hr))
if (FAILED(hr = shader_extract_from_dxbc(byte_code, byte_code_length, &shader_info)))
{
ERR("Failed to extract shader, hr %#x.\n", hr);
return hr;
}
hr = wined3d_shader_create_ps(device->wined3d_device, shader_info.shader_code,
&output_signature, shader, &d3d10_pixel_shader_wined3d_parent_ops, &shader->wined3d_shader, 4);
desc.byte_code = shader_info.shader_code;
desc.input_signature = &input_signature;
desc.output_signature = &output_signature;
desc.max_version = 4;
hr = wined3d_shader_create_ps(device->wined3d_device, &desc, shader,
&d3d10_pixel_shader_wined3d_parent_ops, &shader->wined3d_shader);
shader_free_signature(&input_signature);
shader_free_signature(&output_signature);
if (FAILED(hr))
{
......
......@@ -111,11 +111,19 @@ HRESULT d3d8_vertex_shader_init(struct d3d8_vertex_shader *shader, struct d3d8_d
if (byte_code)
{
if (usage) FIXME("Usage %#x not implemented.\n", usage);
struct wined3d_shader_desc desc;
if (usage)
FIXME("Usage %#x not implemented.\n", usage);
desc.byte_code = byte_code;
desc.input_signature = NULL;
desc.output_signature = NULL;
desc.max_version = 1;
wined3d_mutex_lock();
hr = wined3d_shader_create_vs(device->wined3d_device, byte_code, NULL /* output signature */,
shader, &d3d8_vertexshader_wined3d_parent_ops, &shader->wined3d_shader, 1);
hr = wined3d_shader_create_vs(device->wined3d_device, &desc, shader,
&d3d8_vertexshader_wined3d_parent_ops, &shader->wined3d_shader);
wined3d_mutex_unlock();
if (FAILED(hr))
{
......@@ -152,13 +160,19 @@ static const struct wined3d_parent_ops d3d8_pixelshader_wined3d_parent_ops =
HRESULT d3d8_pixel_shader_init(struct d3d8_pixel_shader *shader, struct d3d8_device *device,
const DWORD *byte_code, DWORD shader_handle)
{
struct wined3d_shader_desc desc;
HRESULT hr;
shader->handle = shader_handle;
desc.byte_code = byte_code;
desc.input_signature = NULL;
desc.output_signature = NULL;
desc.max_version = 1;
wined3d_mutex_lock();
hr = wined3d_shader_create_ps(device->wined3d_device, byte_code, NULL, shader,
&d3d8_pixelshader_wined3d_parent_ops, &shader->wined3d_shader, 1);
hr = wined3d_shader_create_ps(device->wined3d_device, &desc, shader,
&d3d8_pixelshader_wined3d_parent_ops, &shader->wined3d_shader);
wined3d_mutex_unlock();
if (FAILED(hr))
{
......
......@@ -136,14 +136,20 @@ static const struct wined3d_parent_ops d3d9_vertexshader_wined3d_parent_ops =
HRESULT vertexshader_init(struct d3d9_vertexshader *shader, struct d3d9_device *device, const DWORD *byte_code)
{
struct wined3d_shader_desc desc;
HRESULT hr;
shader->refcount = 1;
shader->IDirect3DVertexShader9_iface.lpVtbl = &d3d9_vertexshader_vtbl;
desc.byte_code = byte_code;
desc.input_signature = NULL;
desc.output_signature = NULL;
desc.max_version = 3;
wined3d_mutex_lock();
hr = wined3d_shader_create_vs(device->wined3d_device, byte_code, NULL,
shader, &d3d9_vertexshader_wined3d_parent_ops, &shader->wined3d_shader, 3);
hr = wined3d_shader_create_vs(device->wined3d_device, &desc, shader,
&d3d9_vertexshader_wined3d_parent_ops, &shader->wined3d_shader);
wined3d_mutex_unlock();
if (FAILED(hr))
{
......@@ -280,14 +286,20 @@ static const struct wined3d_parent_ops d3d9_pixelshader_wined3d_parent_ops =
HRESULT pixelshader_init(struct d3d9_pixelshader *shader, struct d3d9_device *device, const DWORD *byte_code)
{
struct wined3d_shader_desc desc;
HRESULT hr;
shader->refcount = 1;
shader->IDirect3DPixelShader9_iface.lpVtbl = &d3d9_pixelshader_vtbl;
desc.byte_code = byte_code;
desc.input_signature = NULL;
desc.output_signature = NULL;
desc.max_version = 3;
wined3d_mutex_lock();
hr = wined3d_shader_create_ps(device->wined3d_device, byte_code, NULL, shader,
&d3d9_pixelshader_wined3d_parent_ops, &shader->wined3d_shader, 3);
hr = wined3d_shader_create_ps(device->wined3d_device, &desc, shader,
&d3d9_pixelshader_wined3d_parent_ops, &shader->wined3d_shader);
wined3d_mutex_unlock();
if (FAILED(hr))
{
......
......@@ -1972,6 +1972,14 @@ struct wined3d_shader_signature
struct wined3d_shader_signature_element *elements;
};
struct wined3d_shader_desc
{
const DWORD *byte_code;
const struct wined3d_shader_signature *input_signature;
const struct wined3d_shader_signature *output_signature;
unsigned int max_version;
};
struct wined3d_parent_ops
{
void (__stdcall *wined3d_object_destroyed)(void *parent);
......@@ -2411,15 +2419,12 @@ ULONG __cdecl wined3d_sampler_decref(struct wined3d_sampler *sampler);
void * __cdecl wined3d_sampler_get_parent(const struct wined3d_sampler *sampler);
ULONG __cdecl wined3d_sampler_incref(struct wined3d_sampler *sampler);
HRESULT __cdecl wined3d_shader_create_gs(struct wined3d_device *device, const DWORD *byte_code,
const struct wined3d_shader_signature *output_signature, void *parent,
const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader, unsigned int max_version);
HRESULT __cdecl wined3d_shader_create_ps(struct wined3d_device *device, const DWORD *byte_code,
const struct wined3d_shader_signature *output_signature, void *parent,
const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader, unsigned int max_version);
HRESULT __cdecl wined3d_shader_create_vs(struct wined3d_device *device, const DWORD *byte_code,
const struct wined3d_shader_signature *output_signature, void *parent,
const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader, unsigned int max_version);
HRESULT __cdecl wined3d_shader_create_gs(struct wined3d_device *device, const struct wined3d_shader_desc *desc,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader);
HRESULT __cdecl wined3d_shader_create_ps(struct wined3d_device *device, const struct wined3d_shader_desc *desc,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader);
HRESULT __cdecl wined3d_shader_create_vs(struct wined3d_device *device, const struct wined3d_shader_desc *desc,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader);
ULONG __cdecl wined3d_shader_decref(struct wined3d_shader *shader);
HRESULT __cdecl wined3d_shader_get_byte_code(const struct wined3d_shader *shader,
void *byte_code, UINT *byte_code_size);
......
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