d3d11: Implement d3d11_device_CreateDomainShader().

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2016-04-01 11:21:42 +02:00 committed by Alexandre Julliard
parent ea92105d41
commit 37416f2282
3 changed files with 224 additions and 2 deletions

View File

@ -264,6 +264,20 @@ struct d3d11_hull_shader
HRESULT d3d11_hull_shader_create(struct d3d_device *device, const void *byte_code, SIZE_T byte_code_length,
struct d3d11_hull_shader **shader) DECLSPEC_HIDDEN;
/* ID3D11DomainShader */
struct d3d11_domain_shader
{
ID3D11DomainShader ID3D11DomainShader_iface;
LONG refcount;
struct wined3d_private_store private_store;
struct wined3d_shader *wined3d_shader;
ID3D11Device *device;
};
HRESULT d3d11_domain_shader_create(struct d3d_device *device, const void *byte_code, SIZE_T byte_code_length,
struct d3d11_domain_shader **shader) DECLSPEC_HIDDEN;
/* ID3D11GeometryShader, ID3D10GeometryShader */
struct d3d_geometry_shader
{

View File

@ -2199,10 +2199,22 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateHullShader(ID3D11Device *ifa
static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDomainShader(ID3D11Device *iface, const void *byte_code,
SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11DomainShader **shader)
{
FIXME("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p stub!\n",
struct d3d_device *device = impl_from_ID3D11Device(iface);
struct d3d11_domain_shader *object;
HRESULT hr;
TRACE("iface %p, byte_code %p, byte_code_length %lu, class_linkage %p, shader %p.\n",
iface, byte_code, byte_code_length, class_linkage, shader);
return E_NOTIMPL;
if (class_linkage)
FIXME("Class linkage is not implemented yet.\n");
if (FAILED(hr = d3d11_domain_shader_create(device, byte_code, byte_code_length, &object)))
return hr;
*shader = &object->ID3D11DomainShader_iface;
return S_OK;
}
static HRESULT STDMETHODCALLTYPE d3d11_device_CreateComputeShader(ID3D11Device *iface, const void *byte_code,

View File

@ -667,6 +667,202 @@ HRESULT d3d11_hull_shader_create(struct d3d_device *device, const void *byte_cod
return S_OK;
}
/* ID3D11DomainShader methods */
static inline struct d3d11_domain_shader *impl_from_ID3D11DomainShader(ID3D11DomainShader *iface)
{
return CONTAINING_RECORD(iface, struct d3d11_domain_shader, ID3D11DomainShader_iface);
}
static HRESULT STDMETHODCALLTYPE d3d11_domain_shader_QueryInterface(ID3D11DomainShader *iface,
REFIID riid, void **object)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
if (IsEqualGUID(riid, &IID_ID3D11DomainShader)
|| IsEqualGUID(riid, &IID_ID3D11DeviceChild)
|| IsEqualGUID(riid, &IID_IUnknown))
{
ID3D11DomainShader_AddRef(iface);
*object = iface;
return S_OK;
}
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
*object = NULL;
return E_NOINTERFACE;
}
static ULONG STDMETHODCALLTYPE d3d11_domain_shader_AddRef(ID3D11DomainShader *iface)
{
struct d3d11_domain_shader *shader = impl_from_ID3D11DomainShader(iface);
ULONG refcount = InterlockedIncrement(&shader->refcount);
TRACE("%p increasing refcount to %u.\n", shader, refcount);
return refcount;
}
static ULONG STDMETHODCALLTYPE d3d11_domain_shader_Release(ID3D11DomainShader *iface)
{
struct d3d11_domain_shader *shader = impl_from_ID3D11DomainShader(iface);
ULONG refcount = InterlockedDecrement(&shader->refcount);
TRACE("%p decreasing refcount to %u.\n", shader, refcount);
if (!refcount)
{
ID3D11Device *device = shader->device;
wined3d_mutex_lock();
wined3d_shader_decref(shader->wined3d_shader);
wined3d_mutex_unlock();
/* Release the device last, it may cause the wined3d device to be
* destroyed. */
ID3D11Device_Release(device);
}
return refcount;
}
static void STDMETHODCALLTYPE d3d11_domain_shader_GetDevice(ID3D11DomainShader *iface,
ID3D11Device **device)
{
struct d3d11_domain_shader *shader = impl_from_ID3D11DomainShader(iface);
TRACE("iface %p, device %p.\n", iface, device);
*device = shader->device;
ID3D11Device_AddRef(*device);
}
static HRESULT STDMETHODCALLTYPE d3d11_domain_shader_GetPrivateData(ID3D11DomainShader *iface,
REFGUID guid, UINT *data_size, void *data)
{
struct d3d11_domain_shader *shader = impl_from_ID3D11DomainShader(iface);
TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return d3d_get_private_data(&shader->private_store, guid, data_size, data);
}
static HRESULT STDMETHODCALLTYPE d3d11_domain_shader_SetPrivateData(ID3D11DomainShader *iface,
REFGUID guid, UINT data_size, const void *data)
{
struct d3d11_domain_shader *shader = impl_from_ID3D11DomainShader(iface);
TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return d3d_set_private_data(&shader->private_store, guid, data_size, data);
}
static HRESULT STDMETHODCALLTYPE d3d11_domain_shader_SetPrivateDataInterface(ID3D11DomainShader *iface,
REFGUID guid, const IUnknown *data)
{
struct d3d11_domain_shader *shader = impl_from_ID3D11DomainShader(iface);
TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
return d3d_set_private_data_interface(&shader->private_store, guid, data);
}
static const struct ID3D11DomainShaderVtbl d3d11_domain_shader_vtbl =
{
/* IUnknown methods */
d3d11_domain_shader_QueryInterface,
d3d11_domain_shader_AddRef,
d3d11_domain_shader_Release,
/* ID3D11DeviceChild methods */
d3d11_domain_shader_GetDevice,
d3d11_domain_shader_GetPrivateData,
d3d11_domain_shader_SetPrivateData,
d3d11_domain_shader_SetPrivateDataInterface,
};
static void STDMETHODCALLTYPE d3d11_domain_shader_wined3d_object_destroyed(void *parent)
{
struct d3d11_domain_shader *shader = parent;
wined3d_private_store_cleanup(&shader->private_store);
HeapFree(GetProcessHeap(), 0, parent);
}
static const struct wined3d_parent_ops d3d11_domain_shader_wined3d_parent_ops =
{
d3d11_domain_shader_wined3d_object_destroyed,
};
static HRESULT d3d11_domain_shader_init(struct d3d11_domain_shader *shader, struct d3d_device *device,
const void *byte_code, SIZE_T byte_code_length)
{
struct wined3d_shader_signature output_signature;
struct wined3d_shader_signature input_signature;
struct d3d_shader_info shader_info;
struct wined3d_shader_desc desc;
HRESULT hr;
shader->ID3D11DomainShader_iface.lpVtbl = &d3d11_domain_shader_vtbl;
shader->refcount = 1;
wined3d_mutex_lock();
wined3d_private_store_init(&shader->private_store);
shader_info.input_signature = &input_signature;
shader_info.output_signature = &output_signature;
if (FAILED(hr = shader_extract_from_dxbc(byte_code, byte_code_length, &shader_info)))
{
WARN("Failed to extract shader, hr %#x.\n", hr);
wined3d_private_store_cleanup(&shader->private_store);
wined3d_mutex_unlock();
return hr;
}
desc.byte_code = shader_info.shader_code;
desc.input_signature = &input_signature;
desc.output_signature = &output_signature;
desc.max_version = d3d_sm_from_feature_level(device->feature_level);
hr = wined3d_shader_create_ds(device->wined3d_device, &desc, shader,
&d3d11_domain_shader_wined3d_parent_ops, &shader->wined3d_shader);
shader_free_signature(&input_signature);
shader_free_signature(&output_signature);
if (FAILED(hr))
{
WARN("Failed to create wined3d domain shader, hr %#x.\n", hr);
wined3d_private_store_cleanup(&shader->private_store);
wined3d_mutex_unlock();
return E_INVALIDARG;
}
wined3d_mutex_unlock();
shader->device = &device->ID3D11Device_iface;
ID3D11Device_AddRef(shader->device);
return S_OK;
}
HRESULT d3d11_domain_shader_create(struct d3d_device *device, const void *byte_code, SIZE_T byte_code_length,
struct d3d11_domain_shader **shader)
{
struct d3d11_domain_shader *object;
HRESULT hr;
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
if (FAILED(hr = d3d11_domain_shader_init(object, device, byte_code, byte_code_length)))
{
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created domain shader %p.\n", object);
*shader = object;
return S_OK;
}
/* ID3D11GeometryShader methods */
static inline struct d3d_geometry_shader *impl_from_ID3D11GeometryShader(ID3D11GeometryShader *iface)