ReactOS  0.4.15-dev-1177-g6cb3b62
shader.c File Reference
#include "config.h"
#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 148 of file shader.c.

149 {
150  TRACE("shader %p.\n", shader);
151 
153  wined3d_shader_decref(shader->wined3d_shader);
155 }
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
ULONG CDECL wined3d_shader_decref(struct wined3d_shader *shader)
Definition: shader.c:3364
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

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 162 of file shader.c.

164 {
165  struct wined3d_shader_desc desc;
166  HRESULT hr;
167 
168  shader->handle = shader_handle;
169 
170  desc.byte_code = byte_code;
171  desc.byte_code_size = ~(size_t)0;
173  desc.input_signature.element_count = 0;
174  desc.output_signature.element_count = 0;
175  desc.patch_constant_signature.element_count = 0;
176  desc.max_version = 1;
177 
179  hr = wined3d_shader_create_ps(device->wined3d_device, &desc, shader,
180  &d3d8_pixelshader_wined3d_parent_ops, &shader->wined3d_shader);
182  if (FAILED(hr))
183  {
184  WARN("Failed to create wined3d pixel shader, hr %#x.\n", hr);
185  return hr;
186  }
187 
188  return D3D_OK;
189 }
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:112
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
const DWORD * byte_code
Definition: wined3d.h:2051
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:4205
static const struct wined3d_parent_ops d3d8_pixelshader_wined3d_parent_ops
Definition: shader.c:157
D3DXCONSTANT_DESC desc
Definition: shader.c:1767
Definition: devices.h:37
__kernel_size_t size_t
Definition: linux.h:237
GLuint shader
Definition: glext.h:6030
LONG HRESULT
Definition: typedefs.h:79
#define D3D_OK
Definition: d3d.h:106
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

Referenced by d3d8_device_CreatePixelShader().

◆ d3d8_pixelshader_wined3d_object_destroyed()

static void STDMETHODCALLTYPE d3d8_pixelshader_wined3d_object_destroyed ( void parent)
static

Definition at line 143 of file shader.c.

144 {
145  heap_free(parent);
146 }
r parent
Definition: btrfs.c:2944
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ d3d8_vertex_shader_destroy()

void d3d8_vertex_shader_destroy ( struct d3d8_vertex_shader shader)

Definition at line 32 of file shader.c.

33 {
34  TRACE("shader %p.\n", shader);
35 
36  if (shader->wined3d_shader)
37  {
39  wined3d_shader_decref(shader->wined3d_shader);
41  }
42  else
43  {
45  }
46 }
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
static void STDMETHODCALLTYPE d3d8_vertexshader_wined3d_object_destroyed(void *parent)
Definition: shader.c:25
ULONG CDECL wined3d_shader_decref(struct wined3d_shader *shader)
Definition: shader.c:3364
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

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 79 of file shader.c.

81 {
82  const DWORD *token = declaration;
83  HRESULT hr;
84 
85  /* Test if the vertex declaration is valid. */
86  while (D3DVSD_END() != *token)
87  {
89 
90  if (token_type == D3DVSD_TOKEN_STREAMDATA && !(token_type & 0x10000000))
91  {
94 
96  {
97  WARN("Attempt to use a non-FLOAT3 normal with the fixed-function function\n");
98  return D3DERR_INVALIDCALL;
99  }
100  }
101  token += parse_token(token);
102  }
103 
104  hr = d3d8_vertexshader_create_vertexdeclaration(device, declaration, shader_handle, &shader->vertex_declaration);
105  if (FAILED(hr))
106  {
107  WARN("Failed to create vertex declaration, hr %#x.\n", hr);
108  return hr;
109  }
110 
111  if (byte_code)
112  {
113  struct wined3d_shader_desc desc;
114 
115  if (usage)
116  FIXME("Usage %#x not implemented.\n", usage);
117 
118  desc.byte_code = byte_code;
119  desc.byte_code_size = ~(size_t)0;
121  desc.input_signature.element_count = 0;
122  desc.output_signature.element_count = 0;
123  desc.patch_constant_signature.element_count = 0;
124  desc.max_version = 1;
125 
127  hr = wined3d_shader_create_vs(device->wined3d_device, &desc, shader,
128  &d3d8_vertexshader_wined3d_parent_ops, &shader->wined3d_shader);
130  if (FAILED(hr))
131  {
132  WARN("Failed to create wined3d vertex shader, hr %#x.\n", hr);
133  d3d8_vertex_declaration_destroy(shader->vertex_declaration);
134  return hr;
135  }
136 
137  load_local_constants(declaration, shader->wined3d_shader);
138  }
139 
140  return D3D_OK;
141 }
HRESULT hr
Definition: shlfolder.c:183
#define D3DVSD_DATATYPESHIFT
Definition: d3d8types.h:245
#define D3DVSD_TOKENTYPEMASK
Definition: d3d8types.h:266
#define WARN(fmt,...)
Definition: debug.h:112
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
#define D3DERR_INVALIDCALL
const DWORD * byte_code
Definition: wined3d.h:2051
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
void d3d8_vertex_declaration_destroy(struct d3d8_vertex_declaration *declaration) DECLSPEC_HIDDEN
#define D3DVSD_END()
Definition: d3d8types.h:275
D3DXCONSTANT_DESC desc
Definition: shader.c:1767
#define D3DVSD_VERTEXREGMASK
Definition: d3d8types.h:257
Definition: devices.h:37
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
#define FIXME(fmt,...)
Definition: debug.h:111
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:53
__kernel_size_t size_t
Definition: linux.h:237
GLuint shader
Definition: glext.h:6030
LONG HRESULT
Definition: typedefs.h:79
#define D3DVSD_TOKENTYPESHIFT
Definition: d3d8types.h:252
unsigned long DWORD
Definition: ntddk_ex.h:95
static const struct wined3d_parent_ops d3d8_vertexshader_wined3d_parent_ops
Definition: shader.c:48
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:4230
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
size_t parse_token(const DWORD *pToken) DECLSPEC_HIDDEN
#define D3DVSD_VERTEXREGSHIFT
Definition: d3d8types.h:243
#define D3D_OK
Definition: d3d.h:106
#define D3DVSD_DATATYPEMASK
Definition: d3d8types.h:259
static int reg
Definition: i386-dis.c:1275
void load_local_constants(const DWORD *d3d8_elements, struct wined3d_shader *wined3d_vertex_shader) DECLSPEC_HIDDEN
enum _D3DVSD_TOKENTYPE D3DVSD_TOKENTYPE
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

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 53 of file shader.c.

55 {
57  HRESULT hr;
58 
59  TRACE("device %p, declaration %p, shader_handle %#x, decl_ptr %p.\n",
60  device, declaration, shader_handle, decl_ptr);
61 
62  if (!(object = heap_alloc_zero(sizeof(*object))))
63  return E_OUTOFMEMORY;
64 
66  if (FAILED(hr))
67  {
68  WARN("Failed to initialize vertex declaration, hr %#x.\n", hr);
69  heap_free(object);
70  return hr;
71  }
72 
73  TRACE("Created vertex declaration %p.\n", object);
74  *decl_ptr = object;
75 
76  return D3D_OK;
77 }
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:112
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
Definition: devices.h:37
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
#define D3D_OK
Definition: d3d.h:106
HRESULT d3d8_vertex_declaration_init(struct d3d8_vertex_declaration *declaration, struct d3d8_device *device, const DWORD *elements, DWORD shader_handle) DECLSPEC_HIDDEN
void * object
Definition: jmemsys.h:48
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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 25 of file shader.c.

26 {
28  d3d8_vertex_declaration_destroy(shader->vertex_declaration);
30 }
void d3d8_vertex_declaration_destroy(struct d3d8_vertex_declaration *declaration) DECLSPEC_HIDDEN
GLuint shader
Definition: glext.h:6030
r parent
Definition: btrfs.c:2944
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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:143

Definition at line 157 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:
=
{
}
static void STDMETHODCALLTYPE d3d8_vertexshader_wined3d_object_destroyed(void *parent)
Definition: shader.c:25

Definition at line 48 of file shader.c.

Referenced by d3d8_vertex_shader_init().