ReactOS 0.4.17-dev-966-gf06eace
shader.c File Reference
#include "d3d8_private.h"
Include dependency graph for shader.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d8)
 
static void STDMETHODCALLTYPE d3d8_vertexshader_wined3d_object_destroyed (void *parent)
 
void d3d8_vertex_shader_destroy (struct d3d8_vertex_shader *shader)
 
static HRESULT d3d8_vertexshader_create_vertexdeclaration (struct d3d8_device *device, const DWORD *declaration, DWORD shader_handle, struct d3d8_vertex_declaration **decl_ptr)
 
HRESULT d3d8_vertex_shader_init (struct d3d8_vertex_shader *shader, struct d3d8_device *device, const DWORD *declaration, const DWORD *byte_code, DWORD shader_handle, DWORD usage)
 
static void STDMETHODCALLTYPE d3d8_pixelshader_wined3d_object_destroyed (void *parent)
 
void d3d8_pixel_shader_destroy (struct d3d8_pixel_shader *shader)
 
HRESULT d3d8_pixel_shader_init (struct d3d8_pixel_shader *shader, struct d3d8_device *device, const DWORD *byte_code, DWORD shader_handle)
 

Variables

static const struct wined3d_parent_ops d3d8_vertexshader_wined3d_parent_ops
 
static const struct wined3d_parent_ops d3d8_pixelshader_wined3d_parent_ops
 

Function Documentation

◆ d3d8_pixel_shader_destroy()

void d3d8_pixel_shader_destroy ( struct d3d8_pixel_shader *  shader)

Definition at line 142 of file shader.c.

143{
144 TRACE("shader %p.\n", shader);
145
147 wined3d_shader_decref(shader->wined3d_shader);
149}
ULONG CDECL wined3d_shader_decref(struct wined3d_shader *shader)
Definition: shader.c:2588
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:544
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:539

Referenced by d3d8_device_DeletePixelShader().

◆ d3d8_pixel_shader_init()

HRESULT d3d8_pixel_shader_init ( struct d3d8_pixel_shader *  shader,
struct d3d8_device *  device,
const DWORD *  byte_code,
DWORD  shader_handle 
)

Definition at line 156 of file shader.c.

158{
160 HRESULT hr;
161
162 shader->handle = shader_handle;
163
164 desc.byte_code = byte_code;
165 desc.byte_code_size = ~(size_t)0;
166
168 hr = wined3d_shader_create_ps(device->wined3d_device, &desc, shader,
171 if (FAILED(hr))
172 {
173 WARN("Failed to create wined3d pixel shader, hr %#lx.\n", hr);
174 return hr;
175 }
176
177 return D3D_OK;
178}
#define WARN(fmt,...)
Definition: precomp.h:61
#define D3D_OK
Definition: d3d.h:106
HRESULT hr
Definition: delayimp.cpp:582
static const struct wined3d_parent_ops d3d8_pixelshader_wined3d_parent_ops
Definition: shader.c:151
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)
Definition: shader.c:3291
unsigned int size_t
Definition: corecrt.h:203
#define FAILED(hr)
Definition: intsafe.h:51
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
Definition: devices.h:37
const DWORD * byte_code
Definition: wined3d.h:2105

Referenced by d3d8_device_CreatePixelShader().

◆ d3d8_pixelshader_wined3d_object_destroyed()

static void STDMETHODCALLTYPE d3d8_pixelshader_wined3d_object_destroyed ( void *  parent)
static

Definition at line 137 of file shader.c.

138{
139 free(parent);
140}
#define free
Definition: debug_ros.c:5
r parent
Definition: btrfs.c:3010

◆ d3d8_vertex_shader_destroy()

void d3d8_vertex_shader_destroy ( struct d3d8_vertex_shader *  shader)

Definition at line 31 of file shader.c.

32{
33 TRACE("shader %p.\n", shader);
34
35 if (shader->wined3d_shader)
36 {
38 wined3d_shader_decref(shader->wined3d_shader);
40 }
41 else
42 {
44 }
45}
static void STDMETHODCALLTYPE d3d8_vertexshader_wined3d_object_destroyed(void *parent)
Definition: shader.c:24

Referenced by d3d8_device_DeleteVertexShader().

◆ d3d8_vertex_shader_init()

HRESULT d3d8_vertex_shader_init ( struct d3d8_vertex_shader *  shader,
struct d3d8_device *  device,
const DWORD *  declaration,
const DWORD *  byte_code,
DWORD  shader_handle,
DWORD  usage 
)

Definition at line 78 of file shader.c.

80{
81 const DWORD *token = declaration;
82 HRESULT hr;
83
84 /* Test if the vertex declaration is valid. */
85 while (D3DVSD_END() != *token)
86 {
88
89 if (token_type == D3DVSD_TOKEN_STREAMDATA && !(token_type & 0x10000000))
90 {
93
94 if (reg == D3DVSDE_NORMAL && type != D3DVSDT_FLOAT3 && !byte_code)
95 {
96 WARN("Attempt to use a non-FLOAT3 normal with the fixed-function function\n");
97 return D3DERR_INVALIDCALL;
98 }
99 }
101 }
102
103 hr = d3d8_vertexshader_create_vertexdeclaration(device, declaration, shader_handle, &shader->vertex_declaration);
104 if (FAILED(hr))
105 {
106 WARN("Failed to create vertex declaration, hr %#lx.\n", hr);
107 return hr;
108 }
109
110 if (byte_code)
111 {
113
114 if (usage)
115 FIXME("Usage %#lx not implemented.\n", usage);
116
117 desc.byte_code = byte_code;
118 desc.byte_code_size = ~(size_t)0;
119
121 hr = wined3d_shader_create_vs(device->wined3d_device, &desc, shader,
124 if (FAILED(hr))
125 {
126 WARN("Failed to create wined3d vertex shader, hr %#lx.\n", hr);
127 d3d8_vertex_declaration_destroy(shader->vertex_declaration);
128 return hr;
129 }
130
131 load_local_constants(declaration, shader->wined3d_shader);
132 }
133
134 return D3D_OK;
135}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define D3DERR_INVALIDCALL
Definition: d3d10_private.h:42
void d3d8_vertex_declaration_destroy(struct d3d8_vertex_declaration *declaration)
void load_local_constants(const DWORD *d3d8_elements, struct wined3d_shader *wined3d_vertex_shader)
size_t parse_token(const DWORD *pToken)
#define D3DVSD_VERTEXREGMASK
Definition: d3d8types.h:257
#define D3DVSD_END()
Definition: d3d8types.h:275
#define D3DVSD_DATATYPEMASK
Definition: d3d8types.h:259
@ D3DVSDE_NORMAL
Definition: d3d8types.h:201
#define D3DVSD_VERTEXREGSHIFT
Definition: d3d8types.h:243
#define D3DVSD_TOKENTYPEMASK
Definition: d3d8types.h:266
#define D3DVSD_DATATYPESHIFT
Definition: d3d8types.h:245
#define D3DVSD_TOKENTYPESHIFT
Definition: d3d8types.h:252
@ D3DVSD_TOKEN_STREAMDATA
Definition: d3d8types.h:167
enum _D3DVSD_TOKENTYPE D3DVSD_TOKENTYPE
@ D3DVSDT_FLOAT3
Definition: d3d8types.h:231
static const struct wined3d_parent_ops d3d8_vertexshader_wined3d_parent_ops
Definition: shader.c:47
static HRESULT d3d8_vertexshader_create_vertexdeclaration(struct d3d8_device *device, const DWORD *declaration, DWORD shader_handle, struct d3d8_vertex_declaration **decl_ptr)
Definition: shader.c:52
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)
Definition: shader.c:3318
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat token
Definition: glfuncs.h:210
static int reg
Definition: i386-dis.c:1290

Referenced by d3d8_device_CreateVertexShader().

◆ d3d8_vertexshader_create_vertexdeclaration()

static HRESULT d3d8_vertexshader_create_vertexdeclaration ( struct d3d8_device *  device,
const DWORD *  declaration,
DWORD  shader_handle,
struct d3d8_vertex_declaration **  decl_ptr 
)
static

Definition at line 52 of file shader.c.

54{
56 HRESULT hr;
57
58 TRACE("device %p, declaration %p, shader_handle %#lx, decl_ptr %p.\n",
59 device, declaration, shader_handle, decl_ptr);
60
61 if (!(object = calloc(1, sizeof(*object))))
62 return E_OUTOFMEMORY;
63
65 if (FAILED(hr))
66 {
67 WARN("Failed to initialize vertex declaration, hr %#lx.\n", hr);
68 free(object);
69 return hr;
70 }
71
72 TRACE("Created vertex declaration %p.\n", object);
73 *decl_ptr = object;
74
75 return D3D_OK;
76}
HRESULT d3d8_vertex_declaration_init(struct d3d8_vertex_declaration *declaration, struct d3d8_device *device, const DWORD *elements, DWORD shader_handle)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define calloc
Definition: rosglue.h:14

Referenced by d3d8_vertex_shader_init().

◆ d3d8_vertexshader_wined3d_object_destroyed()

static void STDMETHODCALLTYPE d3d8_vertexshader_wined3d_object_destroyed ( void *  parent)
static

Definition at line 24 of file shader.c.

Referenced by d3d8_vertex_shader_destroy().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d8  )

Variable Documentation

◆ d3d8_pixelshader_wined3d_parent_ops

const struct wined3d_parent_ops d3d8_pixelshader_wined3d_parent_ops
static
Initial value:
=
{
}
static void STDMETHODCALLTYPE d3d8_pixelshader_wined3d_object_destroyed(void *parent)
Definition: shader.c:137

Definition at line 151 of file shader.c.

Referenced by d3d8_pixel_shader_init().

◆ d3d8_vertexshader_wined3d_parent_ops

const struct wined3d_parent_ops d3d8_vertexshader_wined3d_parent_ops
static
Initial value:

Definition at line 47 of file shader.c.

Referenced by d3d8_vertex_shader_init().