2009-03-04 07:07:38 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Henri Verbeet for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2015-08-21 00:07:53 +02:00
|
|
|
#include "d3d11_private.h"
|
2009-03-04 07:07:38 +01:00
|
|
|
|
2015-08-21 00:07:53 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d11);
|
2009-03-04 07:07:38 +01:00
|
|
|
|
2009-04-27 09:37:14 +02:00
|
|
|
static HRESULT shdr_handler(const char *data, DWORD data_size, DWORD tag, void *ctx)
|
|
|
|
{
|
2009-05-08 17:44:25 +02:00
|
|
|
struct d3d10_shader_info *shader_info = ctx;
|
|
|
|
HRESULT hr;
|
2009-04-27 09:37:14 +02:00
|
|
|
|
2014-11-04 08:47:45 +01:00
|
|
|
switch (tag)
|
2009-04-27 09:37:14 +02:00
|
|
|
{
|
2014-11-04 08:47:45 +01:00
|
|
|
case TAG_ISGN:
|
|
|
|
if (FAILED(hr = shader_parse_signature(data, data_size, shader_info->input_signature)))
|
|
|
|
return hr;
|
|
|
|
break;
|
|
|
|
|
2009-05-08 17:44:25 +02:00
|
|
|
case TAG_OSGN:
|
2014-11-04 08:47:45 +01:00
|
|
|
if (FAILED(hr = shader_parse_signature(data, data_size, shader_info->output_signature)))
|
|
|
|
return hr;
|
2009-05-08 17:44:25 +02:00
|
|
|
break;
|
|
|
|
|
2009-04-27 09:37:14 +02:00
|
|
|
case TAG_SHDR:
|
2009-05-08 17:44:25 +02:00
|
|
|
shader_info->shader_code = (const DWORD *)data;
|
|
|
|
break;
|
2009-04-27 09:37:14 +02:00
|
|
|
|
|
|
|
default:
|
2009-09-09 18:12:40 +02:00
|
|
|
FIXME("Unhandled chunk %s\n", debugstr_an((const char *)&tag, 4));
|
2009-05-08 17:44:25 +02:00
|
|
|
break;
|
2009-04-27 09:37:14 +02:00
|
|
|
}
|
2009-05-08 17:44:25 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2009-04-27 09:37:14 +02:00
|
|
|
}
|
|
|
|
|
2009-09-23 18:42:10 +02:00
|
|
|
static HRESULT shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length, struct d3d10_shader_info *shader_info)
|
2009-04-27 09:37:14 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
2009-05-08 17:44:25 +02:00
|
|
|
shader_info->shader_code = NULL;
|
2014-11-04 08:47:45 +01:00
|
|
|
memset(shader_info->input_signature, 0, sizeof(*shader_info->input_signature));
|
2009-05-08 17:44:25 +02:00
|
|
|
memset(shader_info->output_signature, 0, sizeof(*shader_info->output_signature));
|
2009-04-27 09:37:14 +02:00
|
|
|
|
2009-05-08 17:44:25 +02:00
|
|
|
hr = parse_dxbc(dxbc, dxbc_length, shdr_handler, shader_info);
|
2011-09-23 17:03:20 +02:00
|
|
|
if (!shader_info->shader_code) hr = E_INVALIDARG;
|
2009-05-08 17:44:25 +02:00
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("Failed to parse shader, hr %#x\n", hr);
|
2014-11-04 08:47:45 +01:00
|
|
|
shader_free_signature(shader_info->input_signature);
|
2009-05-08 17:44:25 +02:00
|
|
|
shader_free_signature(shader_info->output_signature);
|
|
|
|
}
|
2009-04-27 09:37:14 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2009-05-08 17:44:25 +02:00
|
|
|
HRESULT shader_parse_signature(const char *data, DWORD data_size, struct wined3d_shader_signature *s)
|
|
|
|
{
|
|
|
|
struct wined3d_shader_signature_element *e;
|
|
|
|
const char *ptr = data;
|
|
|
|
unsigned int i;
|
|
|
|
DWORD count;
|
|
|
|
|
|
|
|
read_dword(&ptr, &count);
|
|
|
|
TRACE("%u elements\n", count);
|
|
|
|
|
|
|
|
skip_dword_unknown(&ptr, 1);
|
|
|
|
|
|
|
|
e = HeapAlloc(GetProcessHeap(), 0, count * sizeof(*e));
|
|
|
|
if (!e)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate input signature memory.\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
UINT name_offset;
|
|
|
|
|
|
|
|
read_dword(&ptr, &name_offset);
|
2014-11-04 08:47:44 +01:00
|
|
|
e[i].semantic_name = data + name_offset;
|
2009-05-08 17:44:25 +02:00
|
|
|
read_dword(&ptr, &e[i].semantic_idx);
|
|
|
|
read_dword(&ptr, &e[i].sysval_semantic);
|
|
|
|
read_dword(&ptr, &e[i].component_type);
|
|
|
|
read_dword(&ptr, &e[i].register_idx);
|
|
|
|
read_dword(&ptr, &e[i].mask);
|
|
|
|
|
|
|
|
TRACE("semantic: %s, semantic idx: %u, sysval_semantic %#x, "
|
|
|
|
"type %u, register idx: %u, use_mask %#x, input_mask %#x\n",
|
2009-09-09 18:12:40 +02:00
|
|
|
debugstr_a(e[i].semantic_name), e[i].semantic_idx, e[i].sysval_semantic,
|
|
|
|
e[i].component_type, e[i].register_idx, (e[i].mask >> 8) & 0xff, e[i].mask & 0xff);
|
2009-05-08 17:44:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
s->elements = e;
|
|
|
|
s->element_count = count;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void shader_free_signature(struct wined3d_shader_signature *s)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, s->elements);
|
|
|
|
}
|
|
|
|
|
2015-09-16 01:30:10 +02:00
|
|
|
/* ID3D11VertexShader methods */
|
|
|
|
|
|
|
|
static inline struct d3d_vertex_shader *impl_from_ID3D11VertexShader(ID3D11VertexShader *iface)
|
2011-07-12 01:51:41 +02:00
|
|
|
{
|
2015-09-16 01:30:10 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct d3d_vertex_shader, ID3D11VertexShader_iface);
|
2011-07-12 01:51:41 +02:00
|
|
|
}
|
|
|
|
|
2015-09-16 01:30:10 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d3d11_vertex_shader_QueryInterface(ID3D11VertexShader *iface,
|
2009-03-04 07:07:38 +01:00
|
|
|
REFIID riid, void **object)
|
|
|
|
{
|
2015-09-16 01:30:10 +02:00
|
|
|
struct d3d_vertex_shader *shader = impl_from_ID3D11VertexShader(iface);
|
2009-03-04 07:07:38 +01:00
|
|
|
|
2015-09-16 01:30:10 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_ID3D11VertexShader)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3D11DeviceChild)
|
2009-03-04 07:07:38 +01:00
|
|
|
|| IsEqualGUID(riid, &IID_IUnknown))
|
|
|
|
{
|
2015-09-16 01:30:10 +02:00
|
|
|
ID3D11VertexShader_AddRef(iface);
|
2009-03-04 07:07:38 +01:00
|
|
|
*object = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-16 01:30:10 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_ID3D10VertexShader)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3D10DeviceChild))
|
|
|
|
{
|
|
|
|
IUnknown_AddRef(&shader->ID3D10VertexShader_iface);
|
|
|
|
*object = &shader->ID3D10VertexShader_iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
2009-03-04 07:07:38 +01:00
|
|
|
|
|
|
|
*object = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2015-09-16 01:30:10 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE d3d11_vertex_shader_AddRef(ID3D11VertexShader *iface)
|
2009-03-04 07:07:38 +01:00
|
|
|
{
|
2015-09-16 01:30:10 +02:00
|
|
|
struct d3d_vertex_shader *shader = impl_from_ID3D11VertexShader(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&shader->refcount);
|
2009-03-04 07:07:38 +01:00
|
|
|
|
2015-09-16 01:30:10 +02:00
|
|
|
TRACE("%p increasing refcount to %u.\n", shader, refcount);
|
2009-03-04 07:07:38 +01:00
|
|
|
|
2009-09-23 18:42:08 +02:00
|
|
|
if (refcount == 1)
|
2014-02-13 10:14:25 +01:00
|
|
|
{
|
2015-09-16 01:30:10 +02:00
|
|
|
ID3D11Device_AddRef(shader->device);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_lock();
|
2015-09-16 01:30:10 +02:00
|
|
|
wined3d_shader_incref(shader->wined3d_shader);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2014-02-13 10:14:25 +01:00
|
|
|
}
|
2009-09-23 18:42:08 +02:00
|
|
|
|
2009-03-04 07:07:38 +01:00
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2015-09-16 01:30:10 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE d3d11_vertex_shader_Release(ID3D11VertexShader *iface)
|
2009-03-04 07:07:38 +01:00
|
|
|
{
|
2015-09-16 01:30:10 +02:00
|
|
|
struct d3d_vertex_shader *shader = impl_from_ID3D11VertexShader(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&shader->refcount);
|
2009-03-04 07:07:38 +01:00
|
|
|
|
2015-09-16 01:30:10 +02:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", shader, refcount);
|
2009-03-04 07:07:38 +01:00
|
|
|
|
|
|
|
if (!refcount)
|
2014-02-13 10:14:25 +01:00
|
|
|
{
|
2015-09-16 01:30:10 +02:00
|
|
|
ID3D11Device *device = shader->device;
|
2014-02-13 10:14:25 +01:00
|
|
|
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_lock();
|
2015-09-16 01:30:10 +02:00
|
|
|
wined3d_shader_decref(shader->wined3d_shader);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2014-02-13 10:14:25 +01:00
|
|
|
/* Release the device last, it may cause the wined3d device to be
|
|
|
|
* destroyed. */
|
2015-09-16 01:30:10 +02:00
|
|
|
ID3D11Device_Release(device);
|
2014-02-13 10:14:25 +01:00
|
|
|
}
|
2009-03-04 07:07:38 +01:00
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2015-09-16 01:30:10 +02:00
|
|
|
static void STDMETHODCALLTYPE d3d11_vertex_shader_GetDevice(ID3D11VertexShader *iface,
|
|
|
|
ID3D11Device **device)
|
|
|
|
{
|
|
|
|
struct d3d_vertex_shader *shader = impl_from_ID3D11VertexShader(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, device %p.\n", iface, device);
|
|
|
|
|
|
|
|
*device = shader->device;
|
|
|
|
ID3D11Device_AddRef(*device);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d11_vertex_shader_GetPrivateData(ID3D11VertexShader *iface,
|
|
|
|
REFGUID guid, UINT *data_size, void *data)
|
|
|
|
{
|
|
|
|
struct d3d_vertex_shader *shader = impl_from_ID3D11VertexShader(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_vertex_shader_SetPrivateData(ID3D11VertexShader *iface,
|
|
|
|
REFGUID guid, UINT data_size, const void *data)
|
|
|
|
{
|
|
|
|
struct d3d_vertex_shader *shader = impl_from_ID3D11VertexShader(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_vertex_shader_SetPrivateDataInterface(ID3D11VertexShader *iface,
|
|
|
|
REFGUID guid, const IUnknown *data)
|
|
|
|
{
|
|
|
|
struct d3d_vertex_shader *shader = impl_from_ID3D11VertexShader(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 ID3D11VertexShaderVtbl d3d11_vertex_shader_vtbl =
|
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
d3d11_vertex_shader_QueryInterface,
|
|
|
|
d3d11_vertex_shader_AddRef,
|
|
|
|
d3d11_vertex_shader_Release,
|
|
|
|
/* ID3D11DeviceChild methods */
|
|
|
|
d3d11_vertex_shader_GetDevice,
|
|
|
|
d3d11_vertex_shader_GetPrivateData,
|
|
|
|
d3d11_vertex_shader_SetPrivateData,
|
|
|
|
d3d11_vertex_shader_SetPrivateDataInterface,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ID3D10VertexShader methods */
|
|
|
|
|
|
|
|
static inline struct d3d_vertex_shader *impl_from_ID3D10VertexShader(ID3D10VertexShader *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct d3d_vertex_shader, ID3D10VertexShader_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IUnknown methods */
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_vertex_shader_QueryInterface(ID3D10VertexShader *iface,
|
|
|
|
REFIID riid, void **object)
|
|
|
|
{
|
|
|
|
struct d3d_vertex_shader *shader = impl_from_ID3D10VertexShader(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
|
|
|
return d3d11_vertex_shader_QueryInterface(&shader->ID3D11VertexShader_iface, riid, object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE d3d10_vertex_shader_AddRef(ID3D10VertexShader *iface)
|
|
|
|
{
|
|
|
|
struct d3d_vertex_shader *shader = impl_from_ID3D10VertexShader(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return d3d11_vertex_shader_AddRef(&shader->ID3D11VertexShader_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE d3d10_vertex_shader_Release(ID3D10VertexShader *iface)
|
|
|
|
{
|
|
|
|
struct d3d_vertex_shader *shader = impl_from_ID3D10VertexShader(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return d3d11_vertex_shader_Release(&shader->ID3D11VertexShader_iface);
|
|
|
|
}
|
|
|
|
|
2009-03-04 07:07:38 +01:00
|
|
|
/* ID3D10DeviceChild methods */
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d3d10_vertex_shader_GetDevice(ID3D10VertexShader *iface, ID3D10Device **device)
|
|
|
|
{
|
2015-09-16 01:30:09 +02:00
|
|
|
struct d3d_vertex_shader *shader = impl_from_ID3D10VertexShader(iface);
|
2014-02-13 10:14:25 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, device %p.\n", iface, device);
|
|
|
|
|
2015-09-16 01:30:10 +02:00
|
|
|
ID3D11Device_QueryInterface(shader->device, &IID_ID3D10Device, (void **)device);
|
2009-03-04 07:07:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_vertex_shader_GetPrivateData(ID3D10VertexShader *iface,
|
|
|
|
REFGUID guid, UINT *data_size, void *data)
|
|
|
|
{
|
2015-09-16 01:30:09 +02:00
|
|
|
struct d3d_vertex_shader *shader = impl_from_ID3D10VertexShader(iface);
|
2015-02-26 10:11:33 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %p, data %p.\n",
|
2009-03-04 07:07:38 +01:00
|
|
|
iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_get_private_data(&shader->private_store, guid, data_size, data);
|
2009-03-04 07:07:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_vertex_shader_SetPrivateData(ID3D10VertexShader *iface,
|
|
|
|
REFGUID guid, UINT data_size, const void *data)
|
|
|
|
{
|
2015-09-16 01:30:09 +02:00
|
|
|
struct d3d_vertex_shader *shader = impl_from_ID3D10VertexShader(iface);
|
2015-02-26 10:11:31 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %u, data %p.\n",
|
2009-03-04 07:07:38 +01:00
|
|
|
iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_set_private_data(&shader->private_store, guid, data_size, data);
|
2009-03-04 07:07:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_vertex_shader_SetPrivateDataInterface(ID3D10VertexShader *iface,
|
|
|
|
REFGUID guid, const IUnknown *data)
|
|
|
|
{
|
2015-09-16 01:30:09 +02:00
|
|
|
struct d3d_vertex_shader *shader = impl_from_ID3D10VertexShader(iface);
|
2009-03-04 07:07:38 +01:00
|
|
|
|
2015-02-26 10:11:32 +01:00
|
|
|
TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_set_private_data_interface(&shader->private_store, guid, data);
|
2009-03-04 07:07:38 +01:00
|
|
|
}
|
|
|
|
|
2009-09-23 18:42:05 +02:00
|
|
|
static const struct ID3D10VertexShaderVtbl d3d10_vertex_shader_vtbl =
|
2009-03-04 07:07:38 +01:00
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
d3d10_vertex_shader_QueryInterface,
|
|
|
|
d3d10_vertex_shader_AddRef,
|
|
|
|
d3d10_vertex_shader_Release,
|
|
|
|
/* ID3D10DeviceChild methods */
|
|
|
|
d3d10_vertex_shader_GetDevice,
|
|
|
|
d3d10_vertex_shader_GetPrivateData,
|
|
|
|
d3d10_vertex_shader_SetPrivateData,
|
|
|
|
d3d10_vertex_shader_SetPrivateDataInterface,
|
|
|
|
};
|
2009-03-04 07:07:38 +01:00
|
|
|
|
2015-09-16 01:30:09 +02:00
|
|
|
static void STDMETHODCALLTYPE d3d_vertex_shader_wined3d_object_destroyed(void *parent)
|
2009-09-23 18:42:08 +02:00
|
|
|
{
|
2015-09-16 01:30:09 +02:00
|
|
|
struct d3d_vertex_shader *shader = parent;
|
2015-02-26 10:11:31 +01:00
|
|
|
|
|
|
|
wined3d_private_store_cleanup(&shader->private_store);
|
2014-11-04 08:47:44 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, parent);
|
2009-09-23 18:42:08 +02:00
|
|
|
}
|
|
|
|
|
2015-09-16 01:30:09 +02:00
|
|
|
static const struct wined3d_parent_ops d3d_vertex_shader_wined3d_parent_ops =
|
2009-09-23 18:42:08 +02:00
|
|
|
{
|
2015-09-16 01:30:09 +02:00
|
|
|
d3d_vertex_shader_wined3d_object_destroyed,
|
2009-09-23 18:42:08 +02:00
|
|
|
};
|
|
|
|
|
2015-09-16 01:30:11 +02:00
|
|
|
static HRESULT d3d_vertex_shader_init(struct d3d_vertex_shader *shader, struct d3d_device *device,
|
2009-09-23 18:42:05 +02:00
|
|
|
const void *byte_code, SIZE_T byte_code_length)
|
|
|
|
{
|
2014-11-04 08:47:44 +01:00
|
|
|
struct wined3d_shader_signature output_signature;
|
2014-11-04 08:47:45 +01:00
|
|
|
struct wined3d_shader_signature input_signature;
|
2009-09-23 18:42:05 +02:00
|
|
|
struct d3d10_shader_info shader_info;
|
2014-11-04 08:47:45 +01:00
|
|
|
struct wined3d_shader_desc desc;
|
2009-09-23 18:42:05 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2015-09-16 01:30:10 +02:00
|
|
|
shader->ID3D11VertexShader_iface.lpVtbl = &d3d11_vertex_shader_vtbl;
|
2011-07-12 01:54:04 +02:00
|
|
|
shader->ID3D10VertexShader_iface.lpVtbl = &d3d10_vertex_shader_vtbl;
|
2009-09-23 18:42:05 +02:00
|
|
|
shader->refcount = 1;
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_lock();
|
2015-02-26 10:11:31 +01:00
|
|
|
wined3d_private_store_init(&shader->private_store);
|
2009-09-23 18:42:05 +02:00
|
|
|
|
2014-11-04 08:47:45 +01:00
|
|
|
shader_info.input_signature = &input_signature;
|
2014-11-04 08:47:44 +01:00
|
|
|
shader_info.output_signature = &output_signature;
|
2014-11-04 08:47:45 +01:00
|
|
|
if (FAILED(hr = shader_extract_from_dxbc(byte_code, byte_code_length, &shader_info)))
|
2009-09-23 18:42:05 +02:00
|
|
|
{
|
|
|
|
ERR("Failed to extract shader, hr %#x.\n", hr);
|
2015-02-26 10:11:31 +01:00
|
|
|
wined3d_private_store_cleanup(&shader->private_store);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2009-09-23 18:42:05 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2014-11-04 08:47:45 +01:00
|
|
|
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,
|
2015-09-16 01:30:09 +02:00
|
|
|
&d3d_vertex_shader_wined3d_parent_ops, &shader->wined3d_shader);
|
2014-11-04 08:47:45 +01:00
|
|
|
shader_free_signature(&input_signature);
|
2014-11-04 08:47:44 +01:00
|
|
|
shader_free_signature(&output_signature);
|
2009-09-23 18:42:05 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to create wined3d vertex shader, hr %#x.\n", hr);
|
2015-02-26 10:11:31 +01:00
|
|
|
wined3d_private_store_cleanup(&shader->private_store);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2014-11-04 08:47:44 +01:00
|
|
|
return E_INVALIDARG;
|
2009-09-23 18:42:05 +02:00
|
|
|
}
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2009-09-23 18:42:05 +02:00
|
|
|
|
2015-09-16 01:30:10 +02:00
|
|
|
shader->device = &device->ID3D11Device_iface;
|
|
|
|
ID3D11Device_AddRef(shader->device);
|
2014-02-13 10:14:25 +01:00
|
|
|
|
2009-09-23 18:42:05 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-16 01:30:11 +02:00
|
|
|
HRESULT d3d_vertex_shader_create(struct d3d_device *device, const void *byte_code, SIZE_T byte_code_length,
|
|
|
|
struct d3d_vertex_shader **shader)
|
|
|
|
{
|
|
|
|
struct d3d_vertex_shader *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(hr = d3d_vertex_shader_init(object, device, byte_code, byte_code_length)))
|
|
|
|
{
|
|
|
|
WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
|
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created vertex shader %p.\n", object);
|
|
|
|
*shader = object;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-16 01:30:09 +02:00
|
|
|
struct d3d_vertex_shader *unsafe_impl_from_ID3D10VertexShader(ID3D10VertexShader *iface)
|
2011-07-12 01:51:41 +02:00
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
|
|
|
assert(iface->lpVtbl == &d3d10_vertex_shader_vtbl);
|
|
|
|
|
|
|
|
return impl_from_ID3D10VertexShader(iface);
|
|
|
|
}
|
|
|
|
|
2011-06-01 10:59:33 +02:00
|
|
|
static inline struct d3d10_geometry_shader *impl_from_ID3D10GeometryShader(ID3D10GeometryShader *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct d3d10_geometry_shader, ID3D10GeometryShader_iface);
|
|
|
|
}
|
|
|
|
|
2009-03-04 07:07:38 +01:00
|
|
|
/* IUnknown methods */
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_geometry_shader_QueryInterface(ID3D10GeometryShader *iface,
|
|
|
|
REFIID riid, void **object)
|
|
|
|
{
|
|
|
|
TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_ID3D10GeometryShader)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3D10DeviceChild)
|
|
|
|
|| IsEqualGUID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
IUnknown_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 d3d10_geometry_shader_AddRef(ID3D10GeometryShader *iface)
|
|
|
|
{
|
2011-06-01 10:59:33 +02:00
|
|
|
struct d3d10_geometry_shader *This = impl_from_ID3D10GeometryShader(iface);
|
2009-03-04 07:07:38 +01:00
|
|
|
ULONG refcount = InterlockedIncrement(&This->refcount);
|
|
|
|
|
|
|
|
TRACE("%p increasing refcount to %u\n", This, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE d3d10_geometry_shader_Release(ID3D10GeometryShader *iface)
|
|
|
|
{
|
2011-06-01 10:59:33 +02:00
|
|
|
struct d3d10_geometry_shader *This = impl_from_ID3D10GeometryShader(iface);
|
2009-03-04 07:07:38 +01:00
|
|
|
ULONG refcount = InterlockedDecrement(&This->refcount);
|
|
|
|
|
|
|
|
TRACE("%p decreasing refcount to %u\n", This, refcount);
|
|
|
|
|
|
|
|
if (!refcount)
|
2015-08-12 17:37:08 +02:00
|
|
|
{
|
|
|
|
wined3d_mutex_lock();
|
2011-03-30 20:49:25 +02:00
|
|
|
wined3d_shader_decref(This->wined3d_shader);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
}
|
2009-03-04 07:07:38 +01:00
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ID3D10DeviceChild methods */
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d3d10_geometry_shader_GetDevice(ID3D10GeometryShader *iface, ID3D10Device **device)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, device %p stub!\n", iface, device);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_geometry_shader_GetPrivateData(ID3D10GeometryShader *iface,
|
|
|
|
REFGUID guid, UINT *data_size, void *data)
|
|
|
|
{
|
2015-02-27 12:29:42 +01:00
|
|
|
struct d3d10_geometry_shader *shader = impl_from_ID3D10GeometryShader(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %p, data %p.\n",
|
2009-03-04 07:07:38 +01:00
|
|
|
iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_get_private_data(&shader->private_store, guid, data_size, data);
|
2009-03-04 07:07:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_geometry_shader_SetPrivateData(ID3D10GeometryShader *iface,
|
|
|
|
REFGUID guid, UINT data_size, const void *data)
|
|
|
|
{
|
2015-02-26 10:11:34 +01:00
|
|
|
struct d3d10_geometry_shader *shader = impl_from_ID3D10GeometryShader(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %u, data %p.\n",
|
2009-03-04 07:07:38 +01:00
|
|
|
iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_set_private_data(&shader->private_store, guid, data_size, data);
|
2009-03-04 07:07:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_geometry_shader_SetPrivateDataInterface(ID3D10GeometryShader *iface,
|
|
|
|
REFGUID guid, const IUnknown *data)
|
|
|
|
{
|
2015-02-26 10:11:35 +01:00
|
|
|
struct d3d10_geometry_shader *shader = impl_from_ID3D10GeometryShader(iface);
|
2009-03-04 07:07:38 +01:00
|
|
|
|
2015-02-26 10:11:35 +01:00
|
|
|
TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_set_private_data_interface(&shader->private_store, guid, data);
|
2009-03-04 07:07:38 +01:00
|
|
|
}
|
|
|
|
|
2009-10-29 18:56:22 +01:00
|
|
|
static const struct ID3D10GeometryShaderVtbl d3d10_geometry_shader_vtbl =
|
2009-03-04 07:07:38 +01:00
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
d3d10_geometry_shader_QueryInterface,
|
|
|
|
d3d10_geometry_shader_AddRef,
|
|
|
|
d3d10_geometry_shader_Release,
|
|
|
|
/* ID3D10DeviceChild methods */
|
|
|
|
d3d10_geometry_shader_GetDevice,
|
|
|
|
d3d10_geometry_shader_GetPrivateData,
|
|
|
|
d3d10_geometry_shader_SetPrivateData,
|
|
|
|
d3d10_geometry_shader_SetPrivateDataInterface,
|
|
|
|
};
|
2009-03-04 07:07:38 +01:00
|
|
|
|
2010-01-03 21:18:24 +01:00
|
|
|
static void STDMETHODCALLTYPE d3d10_geometry_shader_wined3d_object_destroyed(void *parent)
|
2009-10-29 18:56:22 +01:00
|
|
|
{
|
2015-02-26 10:11:34 +01:00
|
|
|
struct d3d10_geometry_shader *shader = parent;
|
|
|
|
|
|
|
|
wined3d_private_store_cleanup(&shader->private_store);
|
2014-11-04 08:47:44 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, parent);
|
2010-01-03 21:18:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wined3d_parent_ops d3d10_geometry_shader_wined3d_parent_ops =
|
|
|
|
{
|
|
|
|
d3d10_geometry_shader_wined3d_object_destroyed,
|
|
|
|
};
|
|
|
|
|
2015-08-21 00:07:56 +02:00
|
|
|
HRESULT d3d10_geometry_shader_init(struct d3d10_geometry_shader *shader, struct d3d_device *device,
|
2010-01-03 21:18:24 +01:00
|
|
|
const void *byte_code, SIZE_T byte_code_length)
|
|
|
|
{
|
2014-11-04 08:47:44 +01:00
|
|
|
struct wined3d_shader_signature output_signature;
|
2014-11-04 08:47:45 +01:00
|
|
|
struct wined3d_shader_signature input_signature;
|
2010-01-03 21:18:24 +01:00
|
|
|
struct d3d10_shader_info shader_info;
|
2014-11-04 08:47:45 +01:00
|
|
|
struct wined3d_shader_desc desc;
|
2010-01-03 21:18:24 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2011-06-01 10:59:33 +02:00
|
|
|
shader->ID3D10GeometryShader_iface.lpVtbl = &d3d10_geometry_shader_vtbl;
|
2009-10-29 18:56:22 +01:00
|
|
|
shader->refcount = 1;
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_lock();
|
2015-02-26 10:11:34 +01:00
|
|
|
wined3d_private_store_init(&shader->private_store);
|
2009-10-29 18:56:22 +01:00
|
|
|
|
2014-11-04 08:47:45 +01:00
|
|
|
shader_info.input_signature = &input_signature;
|
2014-11-04 08:47:44 +01:00
|
|
|
shader_info.output_signature = &output_signature;
|
2014-11-04 08:47:45 +01:00
|
|
|
if (FAILED(hr = shader_extract_from_dxbc(byte_code, byte_code_length, &shader_info)))
|
2010-01-03 21:18:24 +01:00
|
|
|
{
|
|
|
|
ERR("Failed to extract shader, hr %#x.\n", hr);
|
2015-02-26 10:11:34 +01:00
|
|
|
wined3d_private_store_cleanup(&shader->private_store);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2010-01-03 21:18:24 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2014-11-04 08:47:45 +01:00
|
|
|
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);
|
2014-11-04 08:47:44 +01:00
|
|
|
shader_free_signature(&output_signature);
|
2010-01-03 21:18:24 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2011-09-23 17:03:20 +02:00
|
|
|
WARN("Failed to create wined3d geometry shader, hr %#x.\n", hr);
|
2015-02-26 10:11:34 +01:00
|
|
|
wined3d_private_store_cleanup(&shader->private_store);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2014-11-04 08:47:44 +01:00
|
|
|
return E_INVALIDARG;
|
2010-01-03 21:18:24 +01:00
|
|
|
}
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2010-01-03 21:18:24 +01:00
|
|
|
|
2009-10-29 18:56:22 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-11-13 21:24:22 +01:00
|
|
|
struct d3d10_geometry_shader *unsafe_impl_from_ID3D10GeometryShader(ID3D10GeometryShader *iface)
|
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
|
|
|
assert(iface->lpVtbl == &d3d10_geometry_shader_vtbl);
|
|
|
|
|
|
|
|
return impl_from_ID3D10GeometryShader(iface);
|
|
|
|
}
|
|
|
|
|
2015-09-16 01:30:13 +02:00
|
|
|
/* ID3D11PixelShader methods */
|
|
|
|
|
|
|
|
static inline struct d3d_pixel_shader *impl_from_ID3D11PixelShader(ID3D11PixelShader *iface)
|
2011-07-12 01:55:11 +02:00
|
|
|
{
|
2015-09-16 01:30:13 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct d3d_pixel_shader, ID3D11PixelShader_iface);
|
2011-07-12 01:55:11 +02:00
|
|
|
}
|
|
|
|
|
2015-09-16 01:30:13 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE d3d11_pixel_shader_QueryInterface(ID3D11PixelShader *iface,
|
2009-03-04 07:07:38 +01:00
|
|
|
REFIID riid, void **object)
|
|
|
|
{
|
2015-09-16 01:30:13 +02:00
|
|
|
struct d3d_pixel_shader *shader = impl_from_ID3D11PixelShader(iface);
|
2009-03-04 07:07:38 +01:00
|
|
|
|
2015-09-16 01:30:13 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_ID3D11PixelShader)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3D11DeviceChild)
|
2009-03-04 07:07:38 +01:00
|
|
|
|| IsEqualGUID(riid, &IID_IUnknown))
|
|
|
|
{
|
2015-09-16 01:30:13 +02:00
|
|
|
ID3D11PixelShader_AddRef(iface);
|
2009-03-04 07:07:38 +01:00
|
|
|
*object = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-16 01:30:13 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_ID3D10PixelShader)
|
|
|
|
|| IsEqualGUID(riid, &IID_ID3D10DeviceChild))
|
|
|
|
{
|
|
|
|
IUnknown_AddRef(&shader->ID3D10PixelShader_iface);
|
|
|
|
*object = &shader->ID3D10PixelShader_iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
2009-03-04 07:07:38 +01:00
|
|
|
|
|
|
|
*object = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2015-09-16 01:30:13 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE d3d11_pixel_shader_AddRef(ID3D11PixelShader *iface)
|
2009-03-04 07:07:38 +01:00
|
|
|
{
|
2015-09-16 01:30:13 +02:00
|
|
|
struct d3d_pixel_shader *shader = impl_from_ID3D11PixelShader(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&shader->refcount);
|
2009-03-04 07:07:38 +01:00
|
|
|
|
2015-09-16 01:30:13 +02:00
|
|
|
TRACE("%p increasing refcount to %u.\n", shader, refcount);
|
2009-03-04 07:07:38 +01:00
|
|
|
|
2009-09-23 18:42:13 +02:00
|
|
|
if (refcount == 1)
|
2014-02-13 10:14:26 +01:00
|
|
|
{
|
2015-09-16 01:30:13 +02:00
|
|
|
ID3D11Device_AddRef(shader->device);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_lock();
|
2015-09-16 01:30:13 +02:00
|
|
|
wined3d_shader_incref(shader->wined3d_shader);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2014-02-13 10:14:26 +01:00
|
|
|
}
|
2009-09-23 18:42:13 +02:00
|
|
|
|
2009-03-04 07:07:38 +01:00
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2015-09-16 01:30:13 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE d3d11_pixel_shader_Release(ID3D11PixelShader *iface)
|
2009-03-04 07:07:38 +01:00
|
|
|
{
|
2015-09-16 01:30:13 +02:00
|
|
|
struct d3d_pixel_shader *shader = impl_from_ID3D11PixelShader(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&shader->refcount);
|
2009-03-04 07:07:38 +01:00
|
|
|
|
2015-09-16 01:30:13 +02:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", shader, refcount);
|
2009-03-04 07:07:38 +01:00
|
|
|
|
|
|
|
if (!refcount)
|
2014-02-13 10:14:26 +01:00
|
|
|
{
|
2015-09-16 01:30:13 +02:00
|
|
|
ID3D11Device *device = shader->device;
|
2014-02-13 10:14:26 +01:00
|
|
|
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_lock();
|
2015-09-16 01:30:13 +02:00
|
|
|
wined3d_shader_decref(shader->wined3d_shader);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2014-02-13 10:14:26 +01:00
|
|
|
/* Release the device last, it may cause the wined3d device to be
|
|
|
|
* destroyed. */
|
2015-09-16 01:30:13 +02:00
|
|
|
ID3D11Device_Release(device);
|
2014-02-13 10:14:26 +01:00
|
|
|
}
|
2009-03-04 07:07:38 +01:00
|
|
|
|
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2015-09-16 01:30:13 +02:00
|
|
|
static void STDMETHODCALLTYPE d3d11_pixel_shader_GetDevice(ID3D11PixelShader *iface,
|
|
|
|
ID3D11Device **device)
|
|
|
|
{
|
|
|
|
struct d3d_pixel_shader *shader = impl_from_ID3D11PixelShader(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, device %p.\n", iface, device);
|
|
|
|
|
|
|
|
*device = shader->device;
|
|
|
|
ID3D11Device_AddRef(*device);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d11_pixel_shader_GetPrivateData(ID3D11PixelShader *iface,
|
|
|
|
REFGUID guid, UINT *data_size, void *data)
|
|
|
|
{
|
|
|
|
struct d3d_pixel_shader *shader = impl_from_ID3D11PixelShader(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_pixel_shader_SetPrivateData(ID3D11PixelShader *iface,
|
|
|
|
REFGUID guid, UINT data_size, const void *data)
|
|
|
|
{
|
|
|
|
struct d3d_pixel_shader *shader = impl_from_ID3D11PixelShader(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_pixel_shader_SetPrivateDataInterface(ID3D11PixelShader *iface,
|
|
|
|
REFGUID guid, const IUnknown *data)
|
|
|
|
{
|
|
|
|
struct d3d_pixel_shader *shader = impl_from_ID3D11PixelShader(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 ID3D11PixelShaderVtbl d3d11_pixel_shader_vtbl =
|
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
d3d11_pixel_shader_QueryInterface,
|
|
|
|
d3d11_pixel_shader_AddRef,
|
|
|
|
d3d11_pixel_shader_Release,
|
|
|
|
/* ID3D11DeviceChild methods */
|
|
|
|
d3d11_pixel_shader_GetDevice,
|
|
|
|
d3d11_pixel_shader_GetPrivateData,
|
|
|
|
d3d11_pixel_shader_SetPrivateData,
|
|
|
|
d3d11_pixel_shader_SetPrivateDataInterface,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ID3D10PixelShader methods */
|
|
|
|
|
|
|
|
static inline struct d3d_pixel_shader *impl_from_ID3D10PixelShader(ID3D10PixelShader *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct d3d_pixel_shader, ID3D10PixelShader_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IUnknown methods */
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_pixel_shader_QueryInterface(ID3D10PixelShader *iface,
|
|
|
|
REFIID riid, void **object)
|
|
|
|
{
|
|
|
|
struct d3d_pixel_shader *shader = impl_from_ID3D10PixelShader(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
|
|
|
return d3d11_pixel_shader_QueryInterface(&shader->ID3D11PixelShader_iface, riid, object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE d3d10_pixel_shader_AddRef(ID3D10PixelShader *iface)
|
|
|
|
{
|
|
|
|
struct d3d_pixel_shader *shader = impl_from_ID3D10PixelShader(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return d3d11_pixel_shader_AddRef(&shader->ID3D11PixelShader_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG STDMETHODCALLTYPE d3d10_pixel_shader_Release(ID3D10PixelShader *iface)
|
|
|
|
{
|
|
|
|
struct d3d_pixel_shader *shader = impl_from_ID3D10PixelShader(iface);
|
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return d3d11_pixel_shader_Release(&shader->ID3D11PixelShader_iface);
|
|
|
|
}
|
|
|
|
|
2009-03-04 07:07:38 +01:00
|
|
|
/* ID3D10DeviceChild methods */
|
|
|
|
|
|
|
|
static void STDMETHODCALLTYPE d3d10_pixel_shader_GetDevice(ID3D10PixelShader *iface, ID3D10Device **device)
|
|
|
|
{
|
2015-09-16 01:30:12 +02:00
|
|
|
struct d3d_pixel_shader *shader = impl_from_ID3D10PixelShader(iface);
|
2014-02-13 10:14:26 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, device %p.\n", iface, device);
|
|
|
|
|
2015-09-16 01:30:13 +02:00
|
|
|
ID3D11Device_QueryInterface(shader->device, &IID_ID3D10Device, (void **)device);
|
2009-03-04 07:07:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_pixel_shader_GetPrivateData(ID3D10PixelShader *iface,
|
|
|
|
REFGUID guid, UINT *data_size, void *data)
|
|
|
|
{
|
2015-09-16 01:30:12 +02:00
|
|
|
struct d3d_pixel_shader *shader = impl_from_ID3D10PixelShader(iface);
|
2015-02-27 12:29:45 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %p, data %p.\n",
|
2009-03-04 07:07:38 +01:00
|
|
|
iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_get_private_data(&shader->private_store, guid, data_size, data);
|
2009-03-04 07:07:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_pixel_shader_SetPrivateData(ID3D10PixelShader *iface,
|
|
|
|
REFGUID guid, UINT data_size, const void *data)
|
|
|
|
{
|
2015-09-16 01:30:12 +02:00
|
|
|
struct d3d_pixel_shader *shader = impl_from_ID3D10PixelShader(iface);
|
2015-02-27 12:29:43 +01:00
|
|
|
|
|
|
|
TRACE("iface %p, guid %s, data_size %u, data %p.\n",
|
2009-03-04 07:07:38 +01:00
|
|
|
iface, debugstr_guid(guid), data_size, data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_set_private_data(&shader->private_store, guid, data_size, data);
|
2009-03-04 07:07:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE d3d10_pixel_shader_SetPrivateDataInterface(ID3D10PixelShader *iface,
|
|
|
|
REFGUID guid, const IUnknown *data)
|
|
|
|
{
|
2015-09-16 01:30:12 +02:00
|
|
|
struct d3d_pixel_shader *shader = impl_from_ID3D10PixelShader(iface);
|
2009-03-04 07:07:38 +01:00
|
|
|
|
2015-02-27 12:29:44 +01:00
|
|
|
TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data);
|
|
|
|
|
2015-09-03 00:06:50 +02:00
|
|
|
return d3d_set_private_data_interface(&shader->private_store, guid, data);
|
2009-03-04 07:07:38 +01:00
|
|
|
}
|
|
|
|
|
2009-09-23 18:42:10 +02:00
|
|
|
static const struct ID3D10PixelShaderVtbl d3d10_pixel_shader_vtbl =
|
2009-03-04 07:07:38 +01:00
|
|
|
{
|
|
|
|
/* IUnknown methods */
|
|
|
|
d3d10_pixel_shader_QueryInterface,
|
|
|
|
d3d10_pixel_shader_AddRef,
|
|
|
|
d3d10_pixel_shader_Release,
|
|
|
|
/* ID3D10DeviceChild methods */
|
|
|
|
d3d10_pixel_shader_GetDevice,
|
|
|
|
d3d10_pixel_shader_GetPrivateData,
|
|
|
|
d3d10_pixel_shader_SetPrivateData,
|
|
|
|
d3d10_pixel_shader_SetPrivateDataInterface,
|
|
|
|
};
|
2009-09-23 18:42:10 +02:00
|
|
|
|
2015-09-16 01:30:12 +02:00
|
|
|
static void STDMETHODCALLTYPE d3d_pixel_shader_wined3d_object_destroyed(void *parent)
|
2009-09-23 18:42:13 +02:00
|
|
|
{
|
2015-09-16 01:30:12 +02:00
|
|
|
struct d3d_pixel_shader *shader = parent;
|
2015-02-27 12:29:43 +01:00
|
|
|
|
|
|
|
wined3d_private_store_cleanup(&shader->private_store);
|
2014-11-04 08:47:44 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, parent);
|
2009-09-23 18:42:13 +02:00
|
|
|
}
|
|
|
|
|
2015-09-16 01:30:12 +02:00
|
|
|
static const struct wined3d_parent_ops d3d_pixel_shader_wined3d_parent_ops =
|
2009-09-23 18:42:13 +02:00
|
|
|
{
|
2015-09-16 01:30:12 +02:00
|
|
|
d3d_pixel_shader_wined3d_object_destroyed,
|
2009-09-23 18:42:13 +02:00
|
|
|
};
|
|
|
|
|
2015-09-16 01:30:14 +02:00
|
|
|
static HRESULT d3d_pixel_shader_init(struct d3d_pixel_shader *shader, struct d3d_device *device,
|
2009-09-23 18:42:10 +02:00
|
|
|
const void *byte_code, SIZE_T byte_code_length)
|
|
|
|
{
|
2014-11-04 08:47:44 +01:00
|
|
|
struct wined3d_shader_signature output_signature;
|
2014-11-04 08:47:45 +01:00
|
|
|
struct wined3d_shader_signature input_signature;
|
2009-09-23 18:42:10 +02:00
|
|
|
struct d3d10_shader_info shader_info;
|
2014-11-04 08:47:45 +01:00
|
|
|
struct wined3d_shader_desc desc;
|
2009-09-23 18:42:10 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2015-09-16 01:30:13 +02:00
|
|
|
shader->ID3D11PixelShader_iface.lpVtbl = &d3d11_pixel_shader_vtbl;
|
2011-07-12 01:56:39 +02:00
|
|
|
shader->ID3D10PixelShader_iface.lpVtbl = &d3d10_pixel_shader_vtbl;
|
2009-09-23 18:42:10 +02:00
|
|
|
shader->refcount = 1;
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_lock();
|
2015-02-27 12:29:43 +01:00
|
|
|
wined3d_private_store_init(&shader->private_store);
|
2009-09-23 18:42:10 +02:00
|
|
|
|
2014-11-04 08:47:45 +01:00
|
|
|
shader_info.input_signature = &input_signature;
|
2014-11-04 08:47:44 +01:00
|
|
|
shader_info.output_signature = &output_signature;
|
2014-11-04 08:47:45 +01:00
|
|
|
if (FAILED(hr = shader_extract_from_dxbc(byte_code, byte_code_length, &shader_info)))
|
2009-09-23 18:42:10 +02:00
|
|
|
{
|
|
|
|
ERR("Failed to extract shader, hr %#x.\n", hr);
|
2015-02-27 12:29:43 +01:00
|
|
|
wined3d_private_store_cleanup(&shader->private_store);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2009-09-23 18:42:10 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2014-11-04 08:47:45 +01:00
|
|
|
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,
|
2015-09-16 01:30:12 +02:00
|
|
|
&d3d_pixel_shader_wined3d_parent_ops, &shader->wined3d_shader);
|
2014-11-04 08:47:45 +01:00
|
|
|
shader_free_signature(&input_signature);
|
2014-11-04 08:47:44 +01:00
|
|
|
shader_free_signature(&output_signature);
|
2009-09-23 18:42:10 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to create wined3d pixel shader, hr %#x.\n", hr);
|
2015-02-27 12:29:43 +01:00
|
|
|
wined3d_private_store_cleanup(&shader->private_store);
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2014-11-04 08:47:44 +01:00
|
|
|
return E_INVALIDARG;
|
2009-09-23 18:42:10 +02:00
|
|
|
}
|
2015-08-12 17:37:08 +02:00
|
|
|
wined3d_mutex_unlock();
|
2009-09-23 18:42:10 +02:00
|
|
|
|
2015-09-16 01:30:13 +02:00
|
|
|
shader->device = &device->ID3D11Device_iface;
|
|
|
|
ID3D11Device_AddRef(shader->device);
|
2014-02-13 10:14:26 +01:00
|
|
|
|
2009-09-23 18:42:10 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2011-07-12 01:55:11 +02:00
|
|
|
|
2015-09-16 01:30:14 +02:00
|
|
|
HRESULT d3d_pixel_shader_create(struct d3d_device *device, const void *byte_code, SIZE_T byte_code_length,
|
|
|
|
struct d3d_pixel_shader **shader)
|
|
|
|
{
|
|
|
|
struct d3d_pixel_shader *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(hr = d3d_pixel_shader_init(object, device, byte_code, byte_code_length)))
|
|
|
|
{
|
|
|
|
WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
|
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created pixel shader %p.\n", object);
|
|
|
|
*shader = object;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-16 01:30:12 +02:00
|
|
|
struct d3d_pixel_shader *unsafe_impl_from_ID3D10PixelShader(ID3D10PixelShader *iface)
|
2011-07-12 01:55:11 +02:00
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
|
|
|
assert(iface->lpVtbl == &d3d10_pixel_shader_vtbl);
|
|
|
|
|
|
|
|
return impl_from_ID3D10PixelShader(iface);
|
|
|
|
}
|