return S_OK;
}
-HRESULT shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length, struct d3d10_shader_info *shader_info)
+static HRESULT shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length, struct d3d10_shader_info *shader_info)
{
HRESULT hr;
TRACE("%p increasing refcount to %u\n", This, refcount);
+ if (refcount == 1)
+ {
+ IWineD3DVertexShader_AddRef(This->wined3d_shader);
+ }
+
return refcount;
}
if (!refcount)
{
IWineD3DVertexShader_Release(This->wined3d_shader);
- shader_free_signature(&This->output_signature);
- HeapFree(GetProcessHeap(), 0, This);
}
return refcount;
return E_NOTIMPL;
}
-const struct ID3D10VertexShaderVtbl d3d10_vertex_shader_vtbl =
+static const struct ID3D10VertexShaderVtbl d3d10_vertex_shader_vtbl =
{
/* IUnknown methods */
d3d10_vertex_shader_QueryInterface,
d3d10_vertex_shader_SetPrivateDataInterface,
};
+static void STDMETHODCALLTYPE d3d10_vertex_shader_wined3d_object_destroyed(void *parent)
+{
+ struct d3d10_vertex_shader *shader = parent;
+ shader_free_signature(&shader->output_signature);
+ HeapFree(GetProcessHeap(), 0, shader);
+}
+
+static const struct wined3d_parent_ops d3d10_vertex_shader_wined3d_parent_ops =
+{
+ d3d10_vertex_shader_wined3d_object_destroyed,
+};
+
+HRESULT d3d10_vertex_shader_init(struct d3d10_vertex_shader *shader, struct d3d10_device *device,
+ const void *byte_code, SIZE_T byte_code_length)
+{
+ struct d3d10_shader_info shader_info;
+ HRESULT hr;
+
+ shader->vtbl = &d3d10_vertex_shader_vtbl;
+ shader->refcount = 1;
+
+ shader_info.output_signature = &shader->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);
+ return hr;
+ }
+
+ hr = IWineD3DDevice_CreateVertexShader(device->wined3d_device,
+ shader_info.shader_code, &shader->output_signature, &shader->wined3d_shader,
+ (IUnknown *)shader, &d3d10_vertex_shader_wined3d_parent_ops);
+ if (FAILED(hr))
+ {
+ WARN("Failed to create wined3d vertex shader, hr %#x.\n", hr);
+ shader_free_signature(&shader->output_signature);
+ return hr;
+ }
+
+ return S_OK;
+}
+
/* IUnknown methods */
static HRESULT STDMETHODCALLTYPE d3d10_geometry_shader_QueryInterface(ID3D10GeometryShader *iface,
return E_NOTIMPL;
}
-const struct ID3D10GeometryShaderVtbl d3d10_geometry_shader_vtbl =
+static const struct ID3D10GeometryShaderVtbl d3d10_geometry_shader_vtbl =
{
/* IUnknown methods */
d3d10_geometry_shader_QueryInterface,
d3d10_geometry_shader_SetPrivateDataInterface,
};
+HRESULT d3d10_geometry_shader_init(struct d3d10_geometry_shader *shader)
+{
+ shader->vtbl = &d3d10_geometry_shader_vtbl;
+ shader->refcount = 1;
+
+ return S_OK;
+}
+
/* IUnknown methods */
static HRESULT STDMETHODCALLTYPE d3d10_pixel_shader_QueryInterface(ID3D10PixelShader *iface,
TRACE("%p increasing refcount to %u\n", This, refcount);
+ if (refcount == 1)
+ {
+ IWineD3DPixelShader_AddRef(This->wined3d_shader);
+ }
+
return refcount;
}
if (!refcount)
{
IWineD3DPixelShader_Release(This->wined3d_shader);
- shader_free_signature(&This->output_signature);
- HeapFree(GetProcessHeap(), 0, This);
}
return refcount;
return E_NOTIMPL;
}
-const struct ID3D10PixelShaderVtbl d3d10_pixel_shader_vtbl =
+static const struct ID3D10PixelShaderVtbl d3d10_pixel_shader_vtbl =
{
/* IUnknown methods */
d3d10_pixel_shader_QueryInterface,
d3d10_pixel_shader_SetPrivateData,
d3d10_pixel_shader_SetPrivateDataInterface,
};
+
+static void STDMETHODCALLTYPE d3d10_pixel_shader_wined3d_object_destroyed(void *parent)
+{
+ struct d3d10_pixel_shader *shader = parent;
+ shader_free_signature(&shader->output_signature);
+ HeapFree(GetProcessHeap(), 0, shader);
+}
+
+static const struct wined3d_parent_ops d3d10_pixel_shader_wined3d_parent_ops =
+{
+ d3d10_pixel_shader_wined3d_object_destroyed,
+};
+
+HRESULT d3d10_pixel_shader_init(struct d3d10_pixel_shader *shader, struct d3d10_device *device,
+ const void *byte_code, SIZE_T byte_code_length)
+{
+ struct d3d10_shader_info shader_info;
+ HRESULT hr;
+
+ shader->vtbl = &d3d10_pixel_shader_vtbl;
+ shader->refcount = 1;
+
+ shader_info.output_signature = &shader->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);
+ return hr;
+ }
+
+ hr = IWineD3DDevice_CreatePixelShader(device->wined3d_device,
+ shader_info.shader_code, &shader->output_signature, &shader->wined3d_shader,
+ (IUnknown *)shader, &d3d10_pixel_shader_wined3d_parent_ops);
+ if (FAILED(hr))
+ {
+ WARN("Failed to create wined3d pixel shader, hr %#x.\n", hr);
+ shader_free_signature(&shader->output_signature);
+ return hr;
+ }
+
+ return S_OK;
+}