ReactOS 0.4.15-dev-7705-g2320c37
stateblock.c File Reference
#include "config.h"
#include "wine/port.h"
#include "wined3d_private.h"
Include dependency graph for stateblock.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d)
 
static void stateblock_set_bits (DWORD *map, UINT map_size)
 
static void stateblock_savedstates_set_all (struct wined3d_saved_states *states, DWORD vs_consts, DWORD ps_consts)
 
static void stateblock_savedstates_set_pixel (struct wined3d_saved_states *states, const DWORD num_constants)
 
static void stateblock_savedstates_set_vertex (struct wined3d_saved_states *states, const DWORD num_constants)
 
void stateblock_init_contained_states (struct wined3d_stateblock *stateblock)
 
static void stateblock_init_lights (struct wined3d_stateblock *stateblock, struct list *light_map)
 
ULONG CDECL wined3d_stateblock_incref (struct wined3d_stateblock *stateblock)
 
void state_unbind_resources (struct wined3d_state *state)
 
void state_cleanup (struct wined3d_state *state)
 
ULONG CDECL wined3d_stateblock_decref (struct wined3d_stateblock *stateblock)
 
struct wined3d_light_infowined3d_state_get_light (const struct wined3d_state *state, unsigned int idx)
 
void wined3d_state_enable_light (struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, struct wined3d_light_info *light_info, BOOL enable)
 
static void wined3d_state_record_lights (struct wined3d_state *dst_state, const struct wined3d_state *src_state)
 
void CDECL wined3d_stateblock_capture (struct wined3d_stateblock *stateblock)
 
static void apply_lights (struct wined3d_device *device, const struct wined3d_state *state)
 
void CDECL wined3d_stateblock_apply (const struct wined3d_stateblock *stateblock)
 
static void state_init_default (struct wined3d_state *state, const struct wined3d_gl_info *gl_info)
 
void state_init (struct wined3d_state *state, struct wined3d_fb_state *fb, const struct wined3d_gl_info *gl_info, const struct wined3d_d3d_info *d3d_info, DWORD flags)
 
static HRESULT stateblock_init (struct wined3d_stateblock *stateblock, struct wined3d_device *device, enum wined3d_stateblock_type type)
 
HRESULT CDECL wined3d_stateblock_create (struct wined3d_device *device, enum wined3d_stateblock_type type, struct wined3d_stateblock **stateblock)
 

Variables

static const DWORD pixel_states_render []
 
static const DWORD pixel_states_texture []
 
static const DWORD pixel_states_sampler []
 
static const DWORD vertex_states_render []
 
static const DWORD vertex_states_texture []
 
static const DWORD vertex_states_sampler []
 

Function Documentation

◆ apply_lights()

static void apply_lights ( struct wined3d_device device,
const struct wined3d_state state 
)
static

Definition at line 947 of file stateblock.c.

948{
949 UINT i;
950
951 for (i = 0; i < LIGHTMAP_SIZE; ++i)
952 {
953 struct list *e;
954
955 LIST_FOR_EACH(e, &state->light_map[i])
956 {
958
959 wined3d_device_set_light(device, light->OriginalIndex, &light->OriginalParms);
960 wined3d_device_set_light_enable(device, light->OriginalIndex, light->glIndex != -1);
961 }
962 }
963}
static int state
Definition: maze.c:121
Definition: list.h:37
HRESULT CDECL wined3d_device_set_light_enable(struct wined3d_device *device, UINT light_idx, BOOL enable)
Definition: device.c:1741
HRESULT CDECL wined3d_device_set_light(struct wined3d_device *device, UINT light_idx, const struct wined3d_light *light)
Definition: device.c:1580
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 GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
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 light
Definition: glfuncs.h:170
uint32_t entry
Definition: isohybrid.c:63
#define e
Definition: ke_i.h:82
unsigned int UINT
Definition: ndis.h:50
#define LIST_FOR_EACH(cursor, list)
Definition: list.h:188
Definition: devices.h:37
#define LIST_ENTRY(type)
Definition: queue.h:175
#define LIGHTMAP_SIZE

Referenced by wined3d_stateblock_apply().

◆ state_cleanup()

void state_cleanup ( struct wined3d_state state)

Definition at line 528 of file stateblock.c.

529{
530 unsigned int counter;
531
532 if (!(state->flags & WINED3D_STATE_NO_REF))
534
536 {
537 state->lights[counter] = NULL;
538 }
539
540 for (counter = 0; counter < LIGHTMAP_SIZE; ++counter)
541 {
542 struct list *e1, *e2;
543 LIST_FOR_EACH_SAFE(e1, e2, &state->light_map[counter])
544 {
546 list_remove(&light->entry);
548 }
549 }
550}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
static void list_remove(struct list_entry *entry)
Definition: list.h:90
#define NULL
Definition: types.h:112
#define LIST_FOR_EACH_SAFE(cursor, cursor2, list)
Definition: list.h:192
void state_unbind_resources(struct wined3d_state *state)
Definition: stateblock.c:429
#define WINED3D_STATE_NO_REF
#define MAX_ACTIVE_LIGHTS

Referenced by device_init(), wined3d_cs_create(), wined3d_cs_destroy(), wined3d_cs_exec_reset_state(), wined3d_device_decref(), wined3d_device_reset(), and wined3d_stateblock_decref().

◆ state_init()

void state_init ( struct wined3d_state state,
struct wined3d_fb_state fb,
const struct wined3d_gl_info gl_info,
const struct wined3d_d3d_info d3d_info,
DWORD  flags 
)

Definition at line 1310 of file stateblock.c.

1313{
1314 unsigned int i;
1315
1316 state->flags = flags;
1317 state->fb = fb;
1318
1319 for (i = 0; i < LIGHTMAP_SIZE; i++)
1320 {
1321 list_init(&state->light_map[i]);
1322 }
1323
1325 state_init_default(state, gl_info);
1326}
static void list_init(struct list_entry *head)
Definition: list.h:51
GLbitfield flags
Definition: glext.h:7161
static void state_init_default(struct wined3d_state *state, const struct wined3d_gl_info *gl_info)
Definition: stateblock.c:1107
#define WINED3D_STATE_INIT_DEFAULT

Referenced by stateblock_init().

◆ state_init_default()

static void state_init_default ( struct wined3d_state state,
const struct wined3d_gl_info gl_info 
)
static

Definition at line 1107 of file stateblock.c.

1108{
1109 union
1110 {
1111 struct wined3d_line_pattern lp;
1112 DWORD d;
1113 } lp;
1114 union {
1115 float f;
1116 DWORD d;
1117 } tmpfloat;
1118 unsigned int i;
1119 struct wined3d_matrix identity;
1120
1121 TRACE("state %p, gl_info %p.\n", state, gl_info);
1122
1124 state->gl_primitive_type = ~0u;
1125 state->gl_patch_vertices = 0;
1126
1127 /* Set some of the defaults for lights, transforms etc */
1128 state->transforms[WINED3D_TS_PROJECTION] = identity;
1129 state->transforms[WINED3D_TS_VIEW] = identity;
1130 for (i = 0; i < 256; ++i)
1131 {
1132 state->transforms[WINED3D_TS_WORLD_MATRIX(i)] = identity;
1133 }
1134
1135 TRACE("Render states\n");
1136 /* Render states: */
1137 state->render_states[WINED3D_RS_ZENABLE] = WINED3D_ZB_TRUE;
1140 lp.lp.repeat_factor = 0;
1141 lp.lp.line_pattern = 0;
1142 state->render_states[WINED3D_RS_LINEPATTERN] = lp.d;
1143 state->render_states[WINED3D_RS_ZWRITEENABLE] = TRUE;
1144 state->render_states[WINED3D_RS_ALPHATESTENABLE] = FALSE;
1145 state->render_states[WINED3D_RS_LASTPIXEL] = TRUE;
1151 state->render_states[WINED3D_RS_ALPHAREF] = 0;
1152 state->render_states[WINED3D_RS_DITHERENABLE] = FALSE;
1153 state->render_states[WINED3D_RS_ALPHABLENDENABLE] = FALSE;
1154 state->render_states[WINED3D_RS_FOGENABLE] = FALSE;
1155 state->render_states[WINED3D_RS_SPECULARENABLE] = FALSE;
1156 state->render_states[WINED3D_RS_ZVISIBLE] = 0;
1157 state->render_states[WINED3D_RS_FOGCOLOR] = 0;
1159 tmpfloat.f = 0.0f;
1160 state->render_states[WINED3D_RS_FOGSTART] = tmpfloat.d;
1161 tmpfloat.f = 1.0f;
1162 state->render_states[WINED3D_RS_FOGEND] = tmpfloat.d;
1163 tmpfloat.f = 1.0f;
1164 state->render_states[WINED3D_RS_FOGDENSITY] = tmpfloat.d;
1165 state->render_states[WINED3D_RS_EDGEANTIALIAS] = FALSE;
1166 state->render_states[WINED3D_RS_RANGEFOGENABLE] = FALSE;
1167 state->render_states[WINED3D_RS_STENCILENABLE] = FALSE;
1171 state->render_states[WINED3D_RS_STENCILREF] = 0;
1172 state->render_states[WINED3D_RS_STENCILMASK] = 0xffffffff;
1174 state->render_states[WINED3D_RS_STENCILWRITEMASK] = 0xffffffff;
1175 state->render_states[WINED3D_RS_TEXTUREFACTOR] = 0xffffffff;
1176 state->render_states[WINED3D_RS_WRAP0] = 0;
1177 state->render_states[WINED3D_RS_WRAP1] = 0;
1178 state->render_states[WINED3D_RS_WRAP2] = 0;
1179 state->render_states[WINED3D_RS_WRAP3] = 0;
1180 state->render_states[WINED3D_RS_WRAP4] = 0;
1181 state->render_states[WINED3D_RS_WRAP5] = 0;
1182 state->render_states[WINED3D_RS_WRAP6] = 0;
1183 state->render_states[WINED3D_RS_WRAP7] = 0;
1184 state->render_states[WINED3D_RS_CLIPPING] = TRUE;
1185 state->render_states[WINED3D_RS_LIGHTING] = TRUE;
1186 state->render_states[WINED3D_RS_AMBIENT] = 0;
1188 state->render_states[WINED3D_RS_COLORVERTEX] = TRUE;
1189 state->render_states[WINED3D_RS_LOCALVIEWER] = TRUE;
1190 state->render_states[WINED3D_RS_NORMALIZENORMALS] = FALSE;
1196 state->render_states[WINED3D_RS_CLIPPLANEENABLE] = 0;
1198 tmpfloat.f = 1.0f;
1199 state->render_states[WINED3D_RS_POINTSIZE] = tmpfloat.d;
1200 tmpfloat.f = 1.0f;
1201 state->render_states[WINED3D_RS_POINTSIZE_MIN] = tmpfloat.d;
1202 state->render_states[WINED3D_RS_POINTSPRITEENABLE] = FALSE;
1203 state->render_states[WINED3D_RS_POINTSCALEENABLE] = FALSE;
1204 tmpfloat.f = 1.0f;
1205 state->render_states[WINED3D_RS_POINTSCALE_A] = tmpfloat.d;
1206 tmpfloat.f = 0.0f;
1207 state->render_states[WINED3D_RS_POINTSCALE_B] = tmpfloat.d;
1208 tmpfloat.f = 0.0f;
1209 state->render_states[WINED3D_RS_POINTSCALE_C] = tmpfloat.d;
1210 state->render_states[WINED3D_RS_MULTISAMPLEANTIALIAS] = TRUE;
1211 state->render_states[WINED3D_RS_MULTISAMPLEMASK] = 0xffffffff;
1213 tmpfloat.f = 1.0f;
1214 state->render_states[WINED3D_RS_PATCHSEGMENTS] = tmpfloat.d;
1215 state->render_states[WINED3D_RS_DEBUGMONITORTOKEN] = 0xbaadcafe;
1216 tmpfloat.f = gl_info->limits.pointsize_max;
1217 state->render_states[WINED3D_RS_POINTSIZE_MAX] = tmpfloat.d;
1219 tmpfloat.f = 0.0f;
1220 state->render_states[WINED3D_RS_TWEENFACTOR] = tmpfloat.d;
1224 /* states new in d3d9 */
1225 state->render_states[WINED3D_RS_SCISSORTESTENABLE] = FALSE;
1226 state->render_states[WINED3D_RS_SLOPESCALEDEPTHBIAS] = 0;
1227 tmpfloat.f = 1.0f;
1228 state->render_states[WINED3D_RS_MINTESSELLATIONLEVEL] = tmpfloat.d;
1229 state->render_states[WINED3D_RS_MAXTESSELLATIONLEVEL] = tmpfloat.d;
1231 tmpfloat.f = 0.0f;
1232 state->render_states[WINED3D_RS_ADAPTIVETESS_X] = tmpfloat.d;
1233 state->render_states[WINED3D_RS_ADAPTIVETESS_Y] = tmpfloat.d;
1234 tmpfloat.f = 1.0f;
1235 state->render_states[WINED3D_RS_ADAPTIVETESS_Z] = tmpfloat.d;
1236 tmpfloat.f = 0.0f;
1237 state->render_states[WINED3D_RS_ADAPTIVETESS_W] = tmpfloat.d;
1239 state->render_states[WINED3D_RS_TWOSIDEDSTENCILMODE] = FALSE;
1244 state->render_states[WINED3D_RS_BLENDFACTOR] = 0xffffffff;
1245 state->render_states[WINED3D_RS_SRGBWRITEENABLE] = 0;
1246 state->render_states[WINED3D_RS_DEPTHBIAS] = 0;
1247 tmpfloat.f = 0.0f;
1248 state->render_states[WINED3D_RS_DEPTHBIASCLAMP] = tmpfloat.d;
1249 state->render_states[WINED3D_RS_DEPTHCLIP] = TRUE;
1250 state->render_states[WINED3D_RS_WRAP8] = 0;
1251 state->render_states[WINED3D_RS_WRAP9] = 0;
1252 state->render_states[WINED3D_RS_WRAP10] = 0;
1253 state->render_states[WINED3D_RS_WRAP11] = 0;
1254 state->render_states[WINED3D_RS_WRAP12] = 0;
1255 state->render_states[WINED3D_RS_WRAP13] = 0;
1256 state->render_states[WINED3D_RS_WRAP14] = 0;
1257 state->render_states[WINED3D_RS_WRAP15] = 0;
1262 for (i = 0; i < MAX_RENDER_TARGETS; ++i)
1263 state->render_states[WINED3D_RS_COLORWRITE(i)] = 0x0000000f;
1264
1265 /* Texture Stage States - Put directly into state block, we will call function below */
1266 for (i = 0; i < MAX_TEXTURES; ++i)
1267 {
1268 TRACE("Setting up default texture states for texture Stage %u.\n", i);
1269 state->transforms[WINED3D_TS_TEXTURE0 + i] = identity;
1271 state->texture_states[i][WINED3D_TSS_COLOR_ARG1] = WINED3DTA_TEXTURE;
1272 state->texture_states[i][WINED3D_TSS_COLOR_ARG2] = WINED3DTA_CURRENT;
1274 state->texture_states[i][WINED3D_TSS_ALPHA_ARG1] = WINED3DTA_TEXTURE;
1275 state->texture_states[i][WINED3D_TSS_ALPHA_ARG2] = WINED3DTA_CURRENT;
1276 state->texture_states[i][WINED3D_TSS_BUMPENV_MAT00] = 0;
1277 state->texture_states[i][WINED3D_TSS_BUMPENV_MAT01] = 0;
1278 state->texture_states[i][WINED3D_TSS_BUMPENV_MAT10] = 0;
1279 state->texture_states[i][WINED3D_TSS_BUMPENV_MAT11] = 0;
1280 state->texture_states[i][WINED3D_TSS_TEXCOORD_INDEX] = i;
1281 state->texture_states[i][WINED3D_TSS_BUMPENV_LSCALE] = 0;
1282 state->texture_states[i][WINED3D_TSS_BUMPENV_LOFFSET] = 0;
1284 state->texture_states[i][WINED3D_TSS_COLOR_ARG0] = WINED3DTA_CURRENT;
1285 state->texture_states[i][WINED3D_TSS_ALPHA_ARG0] = WINED3DTA_CURRENT;
1286 state->texture_states[i][WINED3D_TSS_RESULT_ARG] = WINED3DTA_CURRENT;
1287 }
1288
1289 for (i = 0 ; i < MAX_COMBINED_SAMPLERS; ++i)
1290 {
1291 TRACE("Setting up default samplers states for sampler %u.\n", i);
1295 state->sampler_states[i][WINED3D_SAMP_BORDER_COLOR] = 0;
1299 state->sampler_states[i][WINED3D_SAMP_MIPMAP_LOD_BIAS] = 0;
1300 state->sampler_states[i][WINED3D_SAMP_MAX_MIP_LEVEL] = 0;
1301 state->sampler_states[i][WINED3D_SAMP_MAX_ANISOTROPY] = 1;
1302 state->sampler_states[i][WINED3D_SAMP_SRGB_TEXTURE] = 0;
1303 /* TODO: Indicates which element of a multielement texture to use. */
1304 state->sampler_states[i][WINED3D_SAMP_ELEMENT_INDEX] = 0;
1305 /* TODO: Vertex offset in the presampled displacement map. */
1306 state->sampler_states[i][WINED3D_SAMP_DMAP_OFFSET] = 0;
1307 }
1308}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
void get_identity_matrix(struct wined3d_matrix *mat)
Definition: utils.c:4886
unsigned long DWORD
Definition: ntddk_ex.h:95
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 GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define d
Definition: ke_i.h:81
#define f
Definition: ke_i.h:83
#define TRACE(s)
Definition: solgame.cpp:4
struct wined3d_gl_limits limits
@ WINED3D_DEGREE_LINEAR
Definition: wined3d.h:95
@ WINED3D_DEGREE_CUBIC
Definition: wined3d.h:97
@ WINED3D_SHADE_GOURAUD
Definition: wined3d.h:480
@ WINED3D_BLEND_OP_ADD
Definition: wined3d.h:433
#define WINED3D_TS_WORLD_MATRIX(index)
Definition: wined3d.h:664
@ WINED3D_FOG_NONE
Definition: wined3d.h:471
@ WINED3D_RS_TEXTUREFACTOR
Definition: wined3d.h:314
@ WINED3D_RS_STENCILFAIL
Definition: wined3d.h:307
@ WINED3D_RS_NORMALDEGREE
Definition: wined3d.h:357
@ WINED3D_RS_WRAP8
Definition: wined3d.h:379
@ WINED3D_RS_LIGHTING
Definition: wined3d.h:324
@ WINED3D_RS_SOFTWAREVERTEXPROCESSING
Definition: wined3d.h:338
@ WINED3D_RS_STENCILENABLE
Definition: wined3d.h:306
@ WINED3D_RS_COLORVERTEX
Definition: wined3d.h:328
@ WINED3D_RS_TWEENFACTOR
Definition: wined3d.h:354
@ WINED3D_RS_FOGCOLOR
Definition: wined3d.h:293
@ WINED3D_RS_WRAP4
Definition: wined3d.h:319
@ WINED3D_RS_WRAP15
Definition: wined3d.h:386
@ WINED3D_RS_ZENABLE
Definition: wined3d.h:269
@ WINED3D_RS_ANTIALIASEDLINEENABLE
Definition: wined3d.h:360
@ WINED3D_RS_SPECULARMATERIALSOURCE
Definition: wined3d.h:333
@ WINED3D_RS_STENCILPASS
Definition: wined3d.h:309
@ WINED3D_RS_WRAP13
Definition: wined3d.h:384
@ WINED3D_RS_DEBUGMONITORTOKEN
Definition: wined3d.h:350
@ WINED3D_RS_WRAP1
Definition: wined3d.h:316
@ WINED3D_RS_WRAP3
Definition: wined3d.h:318
@ WINED3D_RS_DEPTHBIAS
Definition: wined3d.h:378
@ WINED3D_RS_MAXTESSELLATIONLEVEL
Definition: wined3d.h:362
@ WINED3D_RS_DITHERENABLE
Definition: wined3d.h:285
@ WINED3D_RS_SHADEMODE
Definition: wined3d.h:271
@ WINED3D_RS_CULLMODE
Definition: wined3d.h:281
@ WINED3D_RS_BACK_STENCILPASS
Definition: wined3d.h:371
@ WINED3D_RS_PATCHEDGESTYLE
Definition: wined3d.h:348
@ WINED3D_RS_SCISSORTESTENABLE
Definition: wined3d.h:358
@ WINED3D_RS_LASTPIXEL
Definition: wined3d.h:278
@ WINED3D_RS_VERTEXBLEND
Definition: wined3d.h:336
@ WINED3D_RS_FOGEND
Definition: wined3d.h:296
@ WINED3D_RS_MINTESSELLATIONLEVEL
Definition: wined3d.h:361
@ WINED3D_RS_POINTSCALE_A
Definition: wined3d.h:343
@ WINED3D_RS_MULTISAMPLEMASK
Definition: wined3d.h:347
@ WINED3D_RS_BACK_STENCILFUNC
Definition: wined3d.h:372
@ WINED3D_RS_SRCBLEND
Definition: wined3d.h:279
@ WINED3D_RS_SRGBWRITEENABLE
Definition: wined3d.h:377
@ WINED3D_RS_RANGEFOGENABLE
Definition: wined3d.h:302
@ WINED3D_RS_POINTSIZE_MIN
Definition: wined3d.h:340
@ WINED3D_RS_DEPTHCLIP
Definition: wined3d.h:391
@ WINED3D_RS_ENABLEADAPTIVETESSELLATION
Definition: wined3d.h:367
@ WINED3D_RS_ALPHABLENDENABLE
Definition: wined3d.h:286
@ WINED3D_RS_ADAPTIVETESS_X
Definition: wined3d.h:363
@ WINED3D_RS_LOCALVIEWER
Definition: wined3d.h:329
@ WINED3D_RS_ADAPTIVETESS_Z
Definition: wined3d.h:365
@ WINED3D_RS_WRAP0
Definition: wined3d.h:315
@ WINED3D_RS_STENCILMASK
Definition: wined3d.h:312
@ WINED3D_RS_BLENDOP
Definition: wined3d.h:355
@ WINED3D_RS_POINTSCALE_C
Definition: wined3d.h:345
@ WINED3D_RS_FOGSTART
Definition: wined3d.h:295
@ WINED3D_RS_STENCILFUNC
Definition: wined3d.h:310
@ WINED3D_RS_WRAP7
Definition: wined3d.h:322
@ WINED3D_RS_FOGTABLEMODE
Definition: wined3d.h:294
@ WINED3D_RS_POINTSIZE
Definition: wined3d.h:339
@ WINED3D_RS_POINTSIZE_MAX
Definition: wined3d.h:351
@ WINED3D_RS_ZWRITEENABLE
Definition: wined3d.h:276
@ WINED3D_RS_CLIPPLANEENABLE
Definition: wined3d.h:337
@ WINED3D_RS_DESTBLEND
Definition: wined3d.h:280
@ WINED3D_RS_AMBIENTMATERIALSOURCE
Definition: wined3d.h:334
@ WINED3D_RS_WRAP6
Definition: wined3d.h:321
@ WINED3D_RS_STENCILREF
Definition: wined3d.h:311
@ WINED3D_RS_FOGENABLE
Definition: wined3d.h:287
@ WINED3D_RS_POINTSPRITEENABLE
Definition: wined3d.h:341
@ WINED3D_RS_BACK_STENCILZFAIL
Definition: wined3d.h:370
@ WINED3D_RS_ZFUNC
Definition: wined3d.h:282
@ WINED3D_RS_POSITIONDEGREE
Definition: wined3d.h:356
@ WINED3D_RS_MULTISAMPLEANTIALIAS
Definition: wined3d.h:346
@ WINED3D_RS_BACK_STENCILFAIL
Definition: wined3d.h:369
@ WINED3D_RS_SLOPESCALEDEPTHBIAS
Definition: wined3d.h:359
@ WINED3D_RS_DIFFUSEMATERIALSOURCE
Definition: wined3d.h:332
@ WINED3D_RS_DEPTHBIASCLAMP
Definition: wined3d.h:392
@ WINED3D_RS_ALPHAREF
Definition: wined3d.h:283
@ WINED3D_RS_NORMALIZENORMALS
Definition: wined3d.h:330
@ WINED3D_RS_TWOSIDEDSTENCILMODE
Definition: wined3d.h:368
@ WINED3D_RS_EMISSIVEMATERIALSOURCE
Definition: wined3d.h:335
@ WINED3D_RS_PATCHSEGMENTS
Definition: wined3d.h:349
@ WINED3D_RS_SPECULARENABLE
Definition: wined3d.h:288
@ WINED3D_RS_WRAP2
Definition: wined3d.h:317
@ WINED3D_RS_ADAPTIVETESS_W
Definition: wined3d.h:366
@ WINED3D_RS_FILLMODE
Definition: wined3d.h:270
@ WINED3D_RS_CLIPPING
Definition: wined3d.h:323
@ WINED3D_RS_WRAP10
Definition: wined3d.h:381
@ WINED3D_RS_SRCBLENDALPHA
Definition: wined3d.h:388
@ WINED3D_RS_POINTSCALEENABLE
Definition: wined3d.h:342
@ WINED3D_RS_WRAP14
Definition: wined3d.h:385
@ WINED3D_RS_FOGVERTEXMODE
Definition: wined3d.h:327
@ WINED3D_RS_STENCILWRITEMASK
Definition: wined3d.h:313
@ WINED3D_RS_AMBIENT
Definition: wined3d.h:326
@ WINED3D_RS_WRAP11
Definition: wined3d.h:382
@ WINED3D_RS_LINEPATTERN
Definition: wined3d.h:272
@ WINED3D_RS_ZVISIBLE
Definition: wined3d.h:289
@ WINED3D_RS_BLENDFACTOR
Definition: wined3d.h:376
@ WINED3D_RS_BLENDOPALPHA
Definition: wined3d.h:390
@ WINED3D_RS_DESTBLENDALPHA
Definition: wined3d.h:389
@ WINED3D_RS_FOGDENSITY
Definition: wined3d.h:297
@ WINED3D_RS_STENCILZFAIL
Definition: wined3d.h:308
@ WINED3D_RS_POINTSCALE_B
Definition: wined3d.h:344
@ WINED3D_RS_INDEXEDVERTEXBLENDENABLE
Definition: wined3d.h:352
@ WINED3D_RS_WRAP9
Definition: wined3d.h:380
@ WINED3D_RS_SEPARATEALPHABLENDENABLE
Definition: wined3d.h:387
@ WINED3D_RS_WRAP5
Definition: wined3d.h:320
@ WINED3D_RS_ADAPTIVETESS_Y
Definition: wined3d.h:364
@ WINED3D_RS_ALPHATESTENABLE
Definition: wined3d.h:277
@ WINED3D_RS_ALPHAFUNC
Definition: wined3d.h:284
@ WINED3D_RS_WRAP12
Definition: wined3d.h:383
@ WINED3D_RS_EDGEANTIALIAS
Definition: wined3d.h:299
@ WINED3D_PATCH_EDGE_DISCRETE
Definition: wined3d.h:519
@ WINED3D_MCS_COLOR2
Definition: wined3d.h:514
@ WINED3D_MCS_MATERIAL
Definition: wined3d.h:512
@ WINED3D_MCS_COLOR1
Definition: wined3d.h:513
@ WINED3D_SAMP_ELEMENT_INDEX
Definition: wined3d.h:547
@ WINED3D_SAMP_MAX_ANISOTROPY
Definition: wined3d.h:545
@ WINED3D_SAMP_MIPMAP_LOD_BIAS
Definition: wined3d.h:543
@ WINED3D_SAMP_MIN_FILTER
Definition: wined3d.h:541
@ WINED3D_SAMP_SRGB_TEXTURE
Definition: wined3d.h:546
@ WINED3D_SAMP_DMAP_OFFSET
Definition: wined3d.h:548
@ WINED3D_SAMP_MIP_FILTER
Definition: wined3d.h:542
@ WINED3D_SAMP_MAG_FILTER
Definition: wined3d.h:540
@ WINED3D_SAMP_BORDER_COLOR
Definition: wined3d.h:539
@ WINED3D_SAMP_ADDRESS_V
Definition: wined3d.h:537
@ WINED3D_SAMP_ADDRESS_U
Definition: wined3d.h:536
@ WINED3D_SAMP_ADDRESS_W
Definition: wined3d.h:538
@ WINED3D_SAMP_MAX_MIP_LEVEL
Definition: wined3d.h:544
@ WINED3D_TEXF_NONE
Definition: wined3d.h:685
@ WINED3D_TEXF_POINT
Definition: wined3d.h:686
@ WINED3D_TSS_COLOR_ARG2
Definition: wined3d.h:577
@ WINED3D_TSS_BUMPENV_LOFFSET
Definition: wined3d.h:587
@ WINED3D_TSS_ALPHA_OP
Definition: wined3d.h:578
@ WINED3D_TSS_BUMPENV_MAT11
Definition: wined3d.h:584
@ WINED3D_TSS_COLOR_OP
Definition: wined3d.h:575
@ WINED3D_TSS_BUMPENV_MAT10
Definition: wined3d.h:583
@ WINED3D_TSS_TEXCOORD_INDEX
Definition: wined3d.h:585
@ WINED3D_TSS_ALPHA_ARG2
Definition: wined3d.h:580
@ WINED3D_TSS_BUMPENV_MAT01
Definition: wined3d.h:582
@ WINED3D_TSS_ALPHA_ARG0
Definition: wined3d.h:590
@ WINED3D_TSS_BUMPENV_LSCALE
Definition: wined3d.h:586
@ WINED3D_TSS_COLOR_ARG0
Definition: wined3d.h:589
@ WINED3D_TSS_COLOR_ARG1
Definition: wined3d.h:576
@ WINED3D_TSS_ALPHA_ARG1
Definition: wined3d.h:579
@ WINED3D_TSS_RESULT_ARG
Definition: wined3d.h:591
@ WINED3D_TSS_BUMPENV_MAT00
Definition: wined3d.h:581
@ WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
Definition: wined3d.h:588
@ WINED3D_TADDRESS_WRAP
Definition: wined3d.h:639
#define WINED3DTA_CURRENT
Definition: wined3d.h:868
@ WINED3D_TOP_SELECT_ARG1
Definition: wined3d.h:610
@ WINED3D_TOP_DISABLE
Definition: wined3d.h:609
@ WINED3D_TOP_MODULATE
Definition: wined3d.h:612
@ WINED3D_CMP_ALWAYS
Definition: wined3d.h:459
@ WINED3D_CMP_LESSEQUAL
Definition: wined3d.h:455
@ WINED3D_VBF_DISABLE
Definition: wined3d.h:442
@ WINED3D_BLEND_ONE
Definition: wined3d.h:411
@ WINED3D_BLEND_ZERO
Definition: wined3d.h:410
@ WINED3D_ZB_TRUE
Definition: wined3d.h:465
@ WINED3D_TTFF_DISABLE
Definition: wined3d.h:599
@ WINED3D_TS_TEXTURE0
Definition: wined3d.h:650
@ WINED3D_TS_PROJECTION
Definition: wined3d.h:649
@ WINED3D_TS_VIEW
Definition: wined3d.h:648
@ WINED3D_FILL_SOLID
Definition: wined3d.h:488
@ WINED3D_STENCIL_OP_KEEP
Definition: wined3d.h:500
@ WINED3D_CULL_BACK
Definition: wined3d.h:495
#define WINED3DTA_TEXTURE
Definition: wined3d.h:869
static enum wined3d_render_state WINED3D_RS_COLORWRITE(int index)
Definition: wined3d.h:400
#define MAX_TEXTURES
#define MAX_RENDER_TARGETS
#define MAX_COMBINED_SAMPLERS

Referenced by state_init().

◆ state_unbind_resources()

void state_unbind_resources ( struct wined3d_state state)

Definition at line 429 of file stateblock.c.

430{
433 struct wined3d_vertex_declaration *decl;
434 struct wined3d_sampler *sampler;
435 struct wined3d_texture *texture;
436 struct wined3d_buffer *buffer;
437 struct wined3d_shader *shader;
438 unsigned int i, j;
439
440 if ((decl = state->vertex_declaration))
441 {
442 state->vertex_declaration = NULL;
444 }
445
446 for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
447 {
448 if ((texture = state->textures[i]))
449 {
450 state->textures[i] = NULL;
452 }
453 }
454
455 for (i = 0; i < WINED3D_MAX_STREAM_OUTPUT_BUFFERS; ++i)
456 {
457 if ((buffer = state->stream_output[i].buffer))
458 {
459 state->stream_output[i].buffer = NULL;
461 }
462 }
463
464 for (i = 0; i < MAX_STREAMS; ++i)
465 {
466 if ((buffer = state->streams[i].buffer))
467 {
468 state->streams[i].buffer = NULL;
470 }
471 }
472
473 if ((buffer = state->index_buffer))
474 {
475 state->index_buffer = NULL;
477 }
478
479 for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
480 {
481 if ((shader = state->shader[i]))
482 {
483 state->shader[i] = NULL;
485 }
486
487 for (j = 0; j < MAX_CONSTANT_BUFFERS; ++j)
488 {
489 if ((buffer = state->cb[i][j]))
490 {
491 state->cb[i][j] = NULL;
493 }
494 }
495
496 for (j = 0; j < MAX_SAMPLER_OBJECTS; ++j)
497 {
498 if ((sampler = state->sampler[i][j]))
499 {
500 state->sampler[i][j] = NULL;
502 }
503 }
504
505 for (j = 0; j < MAX_SHADER_RESOURCE_VIEWS; ++j)
506 {
507 if ((srv = state->shader_resource_view[i][j]))
508 {
509 state->shader_resource_view[i][j] = NULL;
511 }
512 }
513 }
514
515 for (i = 0; i < WINED3D_PIPELINE_COUNT; ++i)
516 {
517 for (j = 0; j < MAX_UNORDERED_ACCESS_VIEWS; ++j)
518 {
519 if ((uav = state->unordered_access_view[i][j]))
520 {
521 state->unordered_access_view[i][j] = NULL;
523 }
524 }
525 }
526}
ULONG CDECL wined3d_buffer_decref(struct wined3d_buffer *buffer)
Definition: buffer.c:791
ULONG CDECL wined3d_shader_decref(struct wined3d_shader *shader)
Definition: shader.c:3364
ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
Definition: texture.c:1023
ULONG CDECL wined3d_unordered_access_view_decref(struct wined3d_unordered_access_view *view)
Definition: view.c:970
ULONG CDECL wined3d_shader_resource_view_decref(struct wined3d_shader_resource_view *view)
Definition: view.c:671
GLenum GLuint texture
Definition: glext.h:6295
GLuint buffer
Definition: glext.h:5915
GLuint sampler
Definition: glext.h:7283
GLuint shader
Definition: glext.h:6030
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 GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
ULONG CDECL wined3d_sampler_decref(struct wined3d_sampler *sampler)
Definition: sampler.c:53
ULONG CDECL wined3d_vertex_declaration_decref(struct wined3d_vertex_declaration *declaration)
#define WINED3D_MAX_STREAM_OUTPUT_BUFFERS
Definition: wined3d.h:1569
#define MAX_SAMPLER_OBJECTS
#define MAX_CONSTANT_BUFFERS
#define MAX_STREAMS
#define MAX_UNORDERED_ACCESS_VIEWS
@ WINED3D_PIPELINE_COUNT
@ WINED3D_SHADER_TYPE_COUNT
#define MAX_SHADER_RESOURCE_VIEWS

Referenced by state_cleanup(), wined3d_device_reset(), and wined3d_device_uninit_3d().

◆ stateblock_init()

static HRESULT stateblock_init ( struct wined3d_stateblock stateblock,
struct wined3d_device device,
enum wined3d_stateblock_type  type 
)
static

Definition at line 1328 of file stateblock.c.

1330{
1331 const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
1332
1333 stateblock->ref = 1;
1334 stateblock->device = device;
1335 state_init(&stateblock->state, NULL, &device->adapter->gl_info, d3d_info, 0);
1336
1338 return WINED3D_OK;
1339
1340 TRACE("Updating changed flags appropriate for type %#x.\n", type);
1341
1342 switch (type)
1343 {
1344 case WINED3D_SBT_ALL:
1345 stateblock_init_lights(stateblock, device->state.light_map);
1347 d3d_info->limits.vs_uniform_count, d3d_info->limits.ps_uniform_count);
1348 break;
1349
1352 d3d_info->limits.ps_uniform_count);
1353 break;
1354
1356 stateblock_init_lights(stateblock, device->state.light_map);
1358 d3d_info->limits.vs_uniform_count);
1359 break;
1360
1361 default:
1362 FIXME("Unrecognized state block type %#x.\n", type);
1363 break;
1364 }
1365
1367 wined3d_stateblock_capture(stateblock);
1368
1369 return WINED3D_OK;
1370}
#define FIXME(fmt,...)
Definition: debug.h:111
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
struct wined3d_d3d_limits limits
struct wined3d_device * device
struct wined3d_state state
struct wined3d_saved_states changed
static void stateblock_init_lights(struct wined3d_stateblock *stateblock, struct list *light_map)
Definition: stateblock.c:402
void state_init(struct wined3d_state *state, struct wined3d_fb_state *fb, const struct wined3d_gl_info *gl_info, const struct wined3d_d3d_info *d3d_info, DWORD flags)
Definition: stateblock.c:1310
void stateblock_init_contained_states(struct wined3d_stateblock *stateblock)
Definition: stateblock.c:290
static void stateblock_savedstates_set_all(struct wined3d_saved_states *states, DWORD vs_consts, DWORD ps_consts)
Definition: stateblock.c:205
void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock)
Definition: stateblock.c:684
static void stateblock_savedstates_set_pixel(struct wined3d_saved_states *states, const DWORD num_constants)
Definition: stateblock.c:237
static void stateblock_savedstates_set_vertex(struct wined3d_saved_states *states, const DWORD num_constants)
Definition: stateblock.c:263
@ WINED3D_SBT_PIXEL_STATE
Definition: wined3d.h:768
@ WINED3D_SBT_VERTEX_STATE
Definition: wined3d.h:769
@ WINED3D_SBT_ALL
Definition: wined3d.h:767
@ WINED3D_SBT_RECORDED
Definition: wined3d.h:770
#define WINED3D_OK
Definition: wined3d.h:37

◆ stateblock_init_contained_states()

void stateblock_init_contained_states ( struct wined3d_stateblock stateblock)

Definition at line 290 of file stateblock.c.

291{
292 const struct wined3d_d3d_info *d3d_info = &stateblock->device->adapter->d3d_info;
293 unsigned int i, j;
294
295 for (i = 0; i <= WINEHIGHEST_RENDER_STATE >> 5; ++i)
296 {
297 DWORD map = stateblock->changed.renderState[i];
298 for (j = 0; map; map >>= 1, ++j)
299 {
300 if (!(map & 1)) continue;
301
302 stateblock->contained_render_states[stateblock->num_contained_render_states] = (i << 5) | j;
303 ++stateblock->num_contained_render_states;
304 }
305 }
306
307 for (i = 0; i <= HIGHEST_TRANSFORMSTATE >> 5; ++i)
308 {
309 DWORD map = stateblock->changed.transform[i];
310 for (j = 0; map; map >>= 1, ++j)
311 {
312 if (!(map & 1)) continue;
313
314 stateblock->contained_transform_states[stateblock->num_contained_transform_states] = (i << 5) | j;
315 ++stateblock->num_contained_transform_states;
316 }
317 }
318
319 for (i = 0; i < d3d_info->limits.vs_uniform_count; ++i)
320 {
321 if (stateblock->changed.vs_consts_f[i])
322 {
323 stateblock->contained_vs_consts_f[stateblock->num_contained_vs_consts_f] = i;
324 ++stateblock->num_contained_vs_consts_f;
325 }
326 }
327
328 for (i = 0; i < WINED3D_MAX_CONSTS_I; ++i)
329 {
330 if (stateblock->changed.vertexShaderConstantsI & (1u << i))
331 {
332 stateblock->contained_vs_consts_i[stateblock->num_contained_vs_consts_i] = i;
333 ++stateblock->num_contained_vs_consts_i;
334 }
335 }
336
337 for (i = 0; i < WINED3D_MAX_CONSTS_B; ++i)
338 {
339 if (stateblock->changed.vertexShaderConstantsB & (1u << i))
340 {
341 stateblock->contained_vs_consts_b[stateblock->num_contained_vs_consts_b] = i;
342 ++stateblock->num_contained_vs_consts_b;
343 }
344 }
345
346 for (i = 0; i < d3d_info->limits.ps_uniform_count; ++i)
347 {
348 if (stateblock->changed.ps_consts_f[i])
349 {
350 stateblock->contained_ps_consts_f[stateblock->num_contained_ps_consts_f] = i;
351 ++stateblock->num_contained_ps_consts_f;
352 }
353 }
354
355 for (i = 0; i < WINED3D_MAX_CONSTS_I; ++i)
356 {
357 if (stateblock->changed.pixelShaderConstantsI & (1u << i))
358 {
359 stateblock->contained_ps_consts_i[stateblock->num_contained_ps_consts_i] = i;
360 ++stateblock->num_contained_ps_consts_i;
361 }
362 }
363
364 for (i = 0; i < WINED3D_MAX_CONSTS_B; ++i)
365 {
366 if (stateblock->changed.pixelShaderConstantsB & (1u << i))
367 {
368 stateblock->contained_ps_consts_b[stateblock->num_contained_ps_consts_b] = i;
369 ++stateblock->num_contained_ps_consts_b;
370 }
371 }
372
373 for (i = 0; i < MAX_TEXTURES; ++i)
374 {
375 DWORD map = stateblock->changed.textureState[i];
376
377 for(j = 0; map; map >>= 1, ++j)
378 {
379 if (!(map & 1)) continue;
380
381 stateblock->contained_tss_states[stateblock->num_contained_tss_states].stage = i;
382 stateblock->contained_tss_states[stateblock->num_contained_tss_states].state = j;
383 ++stateblock->num_contained_tss_states;
384 }
385 }
386
387 for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
388 {
389 DWORD map = stateblock->changed.samplerState[i];
390
391 for (j = 0; map; map >>= 1, ++j)
392 {
393 if (!(map & 1)) continue;
394
395 stateblock->contained_sampler_states[stateblock->num_contained_sampler_states].stage = i;
396 stateblock->contained_sampler_states[stateblock->num_contained_sampler_states].state = j;
397 ++stateblock->num_contained_sampler_states;
398 }
399 }
400}
Definition: _map.h:48
DWORD contained_vs_consts_f[WINED3D_MAX_VS_CONSTS_F]
unsigned int num_contained_sampler_states
unsigned int num_contained_transform_states
DWORD contained_vs_consts_i[WINED3D_MAX_CONSTS_I]
unsigned int num_contained_vs_consts_i
DWORD contained_render_states[WINEHIGHEST_RENDER_STATE+1]
unsigned int num_contained_vs_consts_b
unsigned int num_contained_ps_consts_f
DWORD contained_transform_states[HIGHEST_TRANSFORMSTATE+1]
unsigned int num_contained_vs_consts_f
unsigned int num_contained_tss_states
unsigned int num_contained_ps_consts_b
struct StageState contained_tss_states[MAX_TEXTURES *(WINED3D_HIGHEST_TEXTURE_STATE+1)]
unsigned int num_contained_ps_consts_i
DWORD contained_ps_consts_i[WINED3D_MAX_CONSTS_I]
DWORD contained_vs_consts_b[WINED3D_MAX_CONSTS_B]
DWORD contained_ps_consts_f[WINED3D_MAX_PS_CONSTS_F]
struct StageState contained_sampler_states[MAX_COMBINED_SAMPLERS *WINED3D_HIGHEST_SAMPLER_STATE]
DWORD contained_ps_consts_b[WINED3D_MAX_CONSTS_B]
unsigned int num_contained_render_states
#define WINED3D_MAX_CONSTS_B
#define WINED3D_MAX_CONSTS_I

Referenced by stateblock_init(), and wined3d_device_end_stateblock().

◆ stateblock_init_lights()

static void stateblock_init_lights ( struct wined3d_stateblock stateblock,
struct list light_map 
)
static

Definition at line 402 of file stateblock.c.

403{
404 unsigned int i;
405
406 for (i = 0; i < LIGHTMAP_SIZE; ++i)
407 {
408 const struct wined3d_light_info *src_light;
409
410 LIST_FOR_EACH_ENTRY(src_light, &light_map[i], struct wined3d_light_info, entry)
411 {
412 struct wined3d_light_info *dst_light = heap_alloc(sizeof(*dst_light));
413
414 *dst_light = *src_light;
415 list_add_tail(&stateblock->state.light_map[i], &dst_light->entry);
416 }
417 }
418}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198

Referenced by stateblock_init().

◆ stateblock_savedstates_set_all()

static void stateblock_savedstates_set_all ( struct wined3d_saved_states states,
DWORD  vs_consts,
DWORD  ps_consts 
)
static

Definition at line 205 of file stateblock.c.

206{
207 unsigned int i;
208
209 /* Single values */
210 states->indices = 1;
211 states->material = 1;
212 states->viewport = 1;
213 states->vertexDecl = 1;
214 states->pixelShader = 1;
215 states->vertexShader = 1;
216 states->scissorRect = 1;
217
218 /* Fixed size arrays */
219 states->streamSource = 0xffff;
220 states->streamFreq = 0xffff;
221 states->textures = 0xfffff;
224 for (i = 0; i < MAX_TEXTURES; ++i) states->textureState[i] = 0x3ffff;
225 for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = 0x3ffe;
226 states->clipplane = (1u << MAX_CLIP_DISTANCES) - 1;
227 states->pixelShaderConstantsB = 0xffff;
228 states->pixelShaderConstantsI = 0xffff;
229 states->vertexShaderConstantsB = 0xffff;
230 states->vertexShaderConstantsI = 0xffff;
231
232 /* Dynamically sized arrays */
233 memset(states->ps_consts_f, TRUE, sizeof(BOOL) * ps_consts);
234 memset(states->vs_consts_f, TRUE, sizeof(BOOL) * vs_consts);
235}
unsigned int BOOL
Definition: ntddk_ex.h:94
#define for
Definition: utility.h:88
#define memset(x, y, z)
Definition: compat.h:39
DWORD textureState[MAX_TEXTURES]
BOOL ps_consts_f[WINED3D_MAX_PS_CONSTS_F]
DWORD renderState[(WINEHIGHEST_RENDER_STATE > > 5)+1]
WORD samplerState[MAX_COMBINED_SAMPLERS]
BOOL vs_consts_f[WINED3D_MAX_VS_CONSTS_F]
DWORD transform[(HIGHEST_TRANSFORMSTATE > > 5)+1]
static void stateblock_set_bits(DWORD *map, UINT map_size)
Definition: stateblock.c:197
#define WINEHIGHEST_RENDER_STATE
Definition: wined3d.h:398
#define HIGHEST_TRANSFORMSTATE
#define MAX_CLIP_DISTANCES

Referenced by stateblock_init().

◆ stateblock_savedstates_set_pixel()

static void stateblock_savedstates_set_pixel ( struct wined3d_saved_states states,
const DWORD  num_constants 
)
static

Definition at line 237 of file stateblock.c.

238{
239 DWORD texture_mask = 0;
240 WORD sampler_mask = 0;
241 unsigned int i;
242
243 states->pixelShader = 1;
244
245 for (i = 0; i < ARRAY_SIZE(pixel_states_render); ++i)
246 {
248 states->renderState[rs >> 5] |= 1u << (rs & 0x1f);
249 }
250
251 for (i = 0; i < ARRAY_SIZE(pixel_states_texture); ++i)
252 texture_mask |= 1u << pixel_states_texture[i];
253 for (i = 0; i < MAX_TEXTURES; ++i) states->textureState[i] = texture_mask;
255 sampler_mask |= 1u << pixel_states_sampler[i];
256 for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = sampler_mask;
257 states->pixelShaderConstantsB = 0xffff;
258 states->pixelShaderConstantsI = 0xffff;
259
260 memset(states->ps_consts_f, TRUE, sizeof(BOOL) * num_constants);
261}
#define ARRAY_SIZE(A)
Definition: main.h:33
unsigned short WORD
Definition: ntddk_ex.h:93
static const DWORD pixel_states_texture[]
Definition: stateblock.c:100
static const DWORD pixel_states_sampler[]
Definition: stateblock.c:121
static const DWORD pixel_states_render[]
Definition: stateblock.c:31

Referenced by stateblock_init().

◆ stateblock_savedstates_set_vertex()

static void stateblock_savedstates_set_vertex ( struct wined3d_saved_states states,
const DWORD  num_constants 
)
static

Definition at line 263 of file stateblock.c.

264{
265 DWORD texture_mask = 0;
266 WORD sampler_mask = 0;
267 unsigned int i;
268
269 states->vertexDecl = 1;
270 states->vertexShader = 1;
271
272 for (i = 0; i < ARRAY_SIZE(vertex_states_render); ++i)
273 {
275 states->renderState[rs >> 5] |= 1u << (rs & 0x1f);
276 }
277
278 for (i = 0; i < ARRAY_SIZE(vertex_states_texture); ++i)
279 texture_mask |= 1u << vertex_states_texture[i];
280 for (i = 0; i < MAX_TEXTURES; ++i) states->textureState[i] = texture_mask;
282 sampler_mask |= 1u << vertex_states_sampler[i];
283 for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = sampler_mask;
284 states->vertexShaderConstantsB = 0xffff;
285 states->vertexShaderConstantsI = 0xffff;
286
287 memset(states->vs_consts_f, TRUE, sizeof(BOOL) * num_constants);
288}
static const DWORD vertex_states_render[]
Definition: stateblock.c:137
static const DWORD vertex_states_sampler[]
Definition: stateblock.c:192
static const DWORD vertex_states_texture[]
Definition: stateblock.c:186

Referenced by stateblock_init().

◆ stateblock_set_bits()

static void stateblock_set_bits ( DWORD map,
UINT  map_size 
)
inlinestatic

Definition at line 197 of file stateblock.c.

198{
199 DWORD mask = (1u << (map_size & 0x1f)) - 1;
200 memset(map, 0xff, (map_size >> 5) * sizeof(*map));
201 if (mask) map[map_size >> 5] = mask;
202}
GLenum GLint GLuint mask
Definition: glext.h:6028

Referenced by stateblock_savedstates_set_all().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d  )

◆ wined3d_state_enable_light()

void wined3d_state_enable_light ( struct wined3d_state state,
const struct wined3d_d3d_info d3d_info,
struct wined3d_light_info light_info,
BOOL  enable 
)

Definition at line 582 of file stateblock.c.

584{
585 unsigned int light_count, i;
586
587 if (!(light_info->enabled = enable))
588 {
589 if (light_info->glIndex == -1)
590 {
591 TRACE("Light already disabled, nothing to do.\n");
592 return;
593 }
594
595 state->lights[light_info->glIndex] = NULL;
596 light_info->glIndex = -1;
597 return;
598 }
599
600 if (light_info->glIndex != -1)
601 {
602 TRACE("Light already enabled, nothing to do.\n");
603 return;
604 }
605
606 /* Find a free light. */
607 light_count = d3d_info->limits.active_light_count;
608 for (i = 0; i < light_count; ++i)
609 {
610 if (state->lights[i])
611 continue;
612
613 state->lights[i] = light_info;
614 light_info->glIndex = i;
615 return;
616 }
617
618 /* Our tests show that Windows returns D3D_OK in this situation, even with
619 * D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE devices.
620 * This is consistent among ddraw, d3d8 and d3d9. GetLightEnable returns
621 * TRUE * as well for those lights.
622 *
623 * TODO: Test how this affects rendering. */
624 WARN("Too many concurrently active lights.\n");
625}
#define WARN(fmt,...)
Definition: debug.h:112
GLboolean enable
Definition: glext.h:11120

Referenced by wined3d_cs_exec_set_light_enable(), and wined3d_device_set_light_enable().

◆ wined3d_state_get_light()

struct wined3d_light_info * wined3d_state_get_light ( const struct wined3d_state state,
unsigned int  idx 
)

Definition at line 567 of file stateblock.c.

568{
569 struct wined3d_light_info *light_info;
570 unsigned int hash_idx;
571
572 hash_idx = LIGHTMAP_HASHFUNC(idx);
573 LIST_FOR_EACH_ENTRY(light_info, &state->light_map[hash_idx], struct wined3d_light_info, entry)
574 {
575 if (light_info->OriginalIndex == idx)
576 return light_info;
577 }
578
579 return NULL;
580}
unsigned int idx
Definition: utils.c:41
#define LIGHTMAP_HASHFUNC(x)

Referenced by wined3d_cs_exec_set_light(), wined3d_cs_exec_set_light_enable(), wined3d_device_get_light(), wined3d_device_get_light_enable(), wined3d_device_set_light(), and wined3d_device_set_light_enable().

◆ wined3d_state_record_lights()

static void wined3d_state_record_lights ( struct wined3d_state dst_state,
const struct wined3d_state src_state 
)
static

Definition at line 627 of file stateblock.c.

628{
629 UINT i;
630
631 /* Lights... For a recorded state block, we just had a chain of actions
632 * to perform, so we need to walk that chain and update any actions which
633 * differ. */
634 for (i = 0; i < LIGHTMAP_SIZE; ++i)
635 {
636 struct list *e, *f;
637 LIST_FOR_EACH(e, &dst_state->light_map[i])
638 {
639 BOOL updated = FALSE;
640 struct wined3d_light_info *src = LIST_ENTRY(e, struct wined3d_light_info, entry), *realLight;
641
642 /* Look up the light in the destination */
643 LIST_FOR_EACH(f, &src_state->light_map[i])
644 {
645 realLight = LIST_ENTRY(f, struct wined3d_light_info, entry);
646 if (realLight->OriginalIndex == src->OriginalIndex)
647 {
648 src->OriginalParms = realLight->OriginalParms;
649
650 if (realLight->glIndex == -1 && src->glIndex != -1)
651 {
652 /* Light disabled */
653 dst_state->lights[src->glIndex] = NULL;
654 }
655 else if (realLight->glIndex != -1 && src->glIndex == -1)
656 {
657 /* Light enabled */
658 dst_state->lights[realLight->glIndex] = src;
659 }
660 src->glIndex = realLight->glIndex;
661 updated = TRUE;
662 break;
663 }
664 }
665
666 if (!updated)
667 {
668 /* This can happen if the light was originally created as a
669 * default light for SetLightEnable() while recording. */
670 WARN("Light %u in dst_state %p does not exist in src_state %p.\n",
671 src->OriginalIndex, dst_state, src_state);
672
673 src->OriginalParms = WINED3D_default_light;
674 if (src->glIndex != -1)
675 {
676 dst_state->lights[src->glIndex] = NULL;
677 src->glIndex = -1;
678 }
679 }
680 }
681 }
682}
const struct wined3d_light WINED3D_default_light
Definition: device.c:41
GLenum src
Definition: glext.h:6340
GLfloat f
Definition: glext.h:7540
const struct wined3d_light_info * lights[MAX_ACTIVE_LIGHTS]
struct list light_map[LIGHTMAP_SIZE]

Referenced by wined3d_stateblock_capture().

◆ wined3d_stateblock_apply()

void CDECL wined3d_stateblock_apply ( const struct wined3d_stateblock stateblock)

Definition at line 965 of file stateblock.c.

966{
967 struct wined3d_device *device = stateblock->device;
968 unsigned int i;
969 DWORD map;
970
971 TRACE("Applying stateblock %p to device %p.\n", stateblock, device);
972
973 if (stateblock->changed.vertexShader)
975
976 /* Vertex Shader Constants. */
977 for (i = 0; i < stateblock->num_contained_vs_consts_f; ++i)
978 {
980 1, &stateblock->state.vs_consts_f[stateblock->contained_vs_consts_f[i]]);
981 }
982 for (i = 0; i < stateblock->num_contained_vs_consts_i; ++i)
983 {
985 1, &stateblock->state.vs_consts_i[stateblock->contained_vs_consts_i[i]]);
986 }
987 for (i = 0; i < stateblock->num_contained_vs_consts_b; ++i)
988 {
990 1, &stateblock->state.vs_consts_b[stateblock->contained_vs_consts_b[i]]);
991 }
992
993 apply_lights(device, &stateblock->state);
994
995 if (stateblock->changed.pixelShader)
997
998 /* Pixel Shader Constants. */
999 for (i = 0; i < stateblock->num_contained_ps_consts_f; ++i)
1000 {
1002 1, &stateblock->state.ps_consts_f[stateblock->contained_ps_consts_f[i]]);
1003 }
1004 for (i = 0; i < stateblock->num_contained_ps_consts_i; ++i)
1005 {
1007 1, &stateblock->state.ps_consts_i[stateblock->contained_ps_consts_i[i]]);
1008 }
1009 for (i = 0; i < stateblock->num_contained_ps_consts_b; ++i)
1010 {
1012 1, &stateblock->state.ps_consts_b[stateblock->contained_ps_consts_b[i]]);
1013 }
1014
1015 /* Render states. */
1016 for (i = 0; i < stateblock->num_contained_render_states; ++i)
1017 {
1019 stateblock->state.render_states[stateblock->contained_render_states[i]]);
1020 }
1021
1022 /* Texture states. */
1023 for (i = 0; i < stateblock->num_contained_tss_states; ++i)
1024 {
1025 DWORD stage = stateblock->contained_tss_states[i].stage;
1026 DWORD state = stateblock->contained_tss_states[i].state;
1027
1028 wined3d_device_set_texture_stage_state(device, stage, state, stateblock->state.texture_states[stage][state]);
1029 }
1030
1031 /* Sampler states. */
1032 for (i = 0; i < stateblock->num_contained_sampler_states; ++i)
1033 {
1034 DWORD stage = stateblock->contained_sampler_states[i].stage;
1035 DWORD state = stateblock->contained_sampler_states[i].state;
1036 DWORD value = stateblock->state.sampler_states[stage][state];
1037
1040 }
1041
1042 /* Transform states. */
1043 for (i = 0; i < stateblock->num_contained_transform_states; ++i)
1044 {
1046 &stateblock->state.transforms[stateblock->contained_transform_states[i]]);
1047 }
1048
1049 if (stateblock->changed.indices)
1050 {
1051 wined3d_device_set_index_buffer(device, stateblock->state.index_buffer,
1052 stateblock->state.index_format, stateblock->state.index_offset);
1053 wined3d_device_set_base_vertex_index(device, stateblock->state.base_vertex_index);
1054 }
1055
1056 if (stateblock->changed.vertexDecl && stateblock->state.vertex_declaration)
1057 wined3d_device_set_vertex_declaration(device, stateblock->state.vertex_declaration);
1058
1059 if (stateblock->changed.material)
1060 wined3d_device_set_material(device, &stateblock->state.material);
1061
1062 if (stateblock->changed.viewport)
1063 wined3d_device_set_viewport(device, &stateblock->state.viewport);
1064
1065 if (stateblock->changed.scissorRect)
1066 wined3d_device_set_scissor_rect(device, &stateblock->state.scissor_rect);
1067
1068 map = stateblock->changed.streamSource;
1069 for (i = 0; map; map >>= 1, ++i)
1070 {
1071 if (map & 1)
1073 stateblock->state.streams[i].buffer,
1074 0, stateblock->state.streams[i].stride);
1075 }
1076
1077 map = stateblock->changed.streamFreq;
1078 for (i = 0; map; map >>= 1, ++i)
1079 {
1080 if (map & 1)
1082 stateblock->state.streams[i].frequency | stateblock->state.streams[i].flags);
1083 }
1084
1085 map = stateblock->changed.textures;
1086 for (i = 0; map; map >>= 1, ++i)
1087 {
1088 DWORD stage;
1089
1090 if (!(map & 1)) continue;
1091
1093 wined3d_device_set_texture(device, stage, stateblock->state.textures[i]);
1094 }
1095
1096 map = stateblock->changed.clipplane;
1097 for (i = 0; map; map >>= 1, ++i)
1098 {
1099 if (!(map & 1)) continue;
1100
1101 wined3d_device_set_clip_plane(device, i, &stateblock->state.clip_planes[i]);
1102 }
1103
1104 TRACE("Applied stateblock %p.\n", stateblock);
1105}
void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device, struct wined3d_vertex_declaration *declaration)
Definition: device.c:2157
HRESULT CDECL wined3d_device_set_vs_consts_f(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants)
Definition: device.c:2463
HRESULT CDECL wined3d_device_set_stream_source_freq(struct wined3d_device *device, UINT stream_idx, UINT divider)
Definition: device.c:1451
void CDECL wined3d_device_set_base_vertex_index(struct wined3d_device *device, INT base_index)
Definition: device.c:1917
void CDECL wined3d_device_set_pixel_shader(struct wined3d_device *device, struct wined3d_shader *shader)
Definition: device.c:2509
void CDECL wined3d_device_set_material(struct wined3d_device *device, const struct wined3d_material *material)
Definition: device.c:1849
void CDECL wined3d_device_set_transform(struct wined3d_device *device, enum wined3d_transform_state d3dts, const struct wined3d_matrix *matrix)
Definition: device.c:1505
void CDECL wined3d_device_set_scissor_rect(struct wined3d_device *device, const RECT *rect)
Definition: device.c:2126
void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader)
Definition: device.c:2186
HRESULT CDECL wined3d_device_set_ps_consts_f(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants)
Definition: device.c:2679
HRESULT CDECL wined3d_device_set_texture(struct wined3d_device *device, UINT stage, struct wined3d_texture *texture)
Definition: device.c:3462
void CDECL wined3d_device_set_sampler_state(struct wined3d_device *device, UINT sampler_idx, enum wined3d_sampler_state state, DWORD value)
Definition: device.c:2071
void CDECL wined3d_device_set_index_buffer(struct wined3d_device *device, struct wined3d_buffer *buffer, enum wined3d_format_id format_id, unsigned int offset)
Definition: device.c:1874
void CDECL wined3d_device_set_viewport(struct wined3d_device *device, const struct wined3d_viewport *viewport)
Definition: device.c:1931
HRESULT CDECL wined3d_device_set_vs_consts_i(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants)
Definition: device.c:2415
void CDECL wined3d_device_set_texture_stage_state(struct wined3d_device *device, UINT stage, enum wined3d_texture_stage_state state, DWORD value)
Definition: device.c:3405
void CDECL wined3d_device_set_render_state(struct wined3d_device *device, enum wined3d_render_state state, DWORD value)
Definition: device.c:2027
HRESULT CDECL wined3d_device_set_clip_plane(struct wined3d_device *device, UINT plane_idx, const struct wined3d_vec4 *plane)
Definition: device.c:1783
HRESULT CDECL wined3d_device_set_ps_consts_i(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants)
Definition: device.c:2630
HRESULT CDECL wined3d_device_set_stream_source(struct wined3d_device *device, UINT stream_idx, struct wined3d_buffer *buffer, UINT offset, UINT stride)
Definition: device.c:1378
HRESULT CDECL wined3d_device_set_ps_consts_b(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const BOOL *constants)
Definition: device.c:2581
HRESULT CDECL wined3d_device_set_vs_consts_b(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const BOOL *constants)
Definition: device.c:2366
Definition: pdh_main.c:94
static void apply_lights(struct wined3d_device *device, const struct wined3d_state *state)
Definition: stateblock.c:947
#define WINED3DVERTEXTEXTURESAMPLER0
Definition: wined3d.h:1025
#define MAX_FRAGMENT_SAMPLERS
@ WINED3D_SHADER_TYPE_PIXEL
@ WINED3D_SHADER_TYPE_VERTEX

Referenced by d3d8_device_ApplyStateBlock(), d3d9_stateblock_Apply(), d3d_device7_ApplyStateBlock(), and ddraw_set_cooperative_level().

◆ wined3d_stateblock_capture()

void CDECL wined3d_stateblock_capture ( struct wined3d_stateblock stateblock)

Definition at line 684 of file stateblock.c.

685{
686 const struct wined3d_state *src_state = &stateblock->device->state;
687 unsigned int i;
688 DWORD map;
689
690 TRACE("stateblock %p.\n", stateblock);
691
692 TRACE("Capturing state %p.\n", src_state);
693
694 if (stateblock->changed.vertexShader && stateblock->state.shader[WINED3D_SHADER_TYPE_VERTEX]
695 != src_state->shader[WINED3D_SHADER_TYPE_VERTEX])
696 {
697 TRACE("Updating vertex shader from %p to %p\n",
698 stateblock->state.shader[WINED3D_SHADER_TYPE_VERTEX],
700
701 if (src_state->shader[WINED3D_SHADER_TYPE_VERTEX])
703 if (stateblock->state.shader[WINED3D_SHADER_TYPE_VERTEX])
705 stateblock->state.shader[WINED3D_SHADER_TYPE_VERTEX] = src_state->shader[WINED3D_SHADER_TYPE_VERTEX];
706 }
707
708 /* Vertex shader float constants. */
709 for (i = 0; i < stateblock->num_contained_vs_consts_f; ++i)
710 {
711 unsigned int idx = stateblock->contained_vs_consts_f[i];
712
713 TRACE("Setting vs_consts_f[%u] to %s.\n", idx, debug_vec4(&src_state->vs_consts_f[idx]));
714
715 stateblock->state.vs_consts_f[idx] = src_state->vs_consts_f[idx];
716 }
717
718 /* Vertex shader integer constants. */
719 for (i = 0; i < stateblock->num_contained_vs_consts_i; ++i)
720 {
721 unsigned int idx = stateblock->contained_vs_consts_i[i];
722
723 TRACE("Setting vs_consts[%u] to %s.\n", idx, debug_ivec4(&src_state->vs_consts_i[idx]));
724
725 stateblock->state.vs_consts_i[idx] = src_state->vs_consts_i[idx];
726 }
727
728 /* Vertex shader boolean constants. */
729 for (i = 0; i < stateblock->num_contained_vs_consts_b; ++i)
730 {
731 unsigned int idx = stateblock->contained_vs_consts_b[i];
732
733 TRACE("Setting vs_consts_b[%u] to %s.\n",
734 idx, src_state->vs_consts_b[idx] ? "TRUE" : "FALSE");
735
736 stateblock->state.vs_consts_b[idx] = src_state->vs_consts_b[idx];
737 }
738
739 /* Pixel shader float constants. */
740 for (i = 0; i < stateblock->num_contained_ps_consts_f; ++i)
741 {
742 unsigned int idx = stateblock->contained_ps_consts_f[i];
743
744 TRACE("Setting ps_consts_f[%u] to %s.\n", idx, debug_vec4(&src_state->ps_consts_f[idx]));
745
746 stateblock->state.ps_consts_f[idx] = src_state->ps_consts_f[idx];
747 }
748
749 /* Pixel shader integer constants. */
750 for (i = 0; i < stateblock->num_contained_ps_consts_i; ++i)
751 {
752 unsigned int idx = stateblock->contained_ps_consts_i[i];
753
754 TRACE("Setting ps_consts_i[%u] to %s.\n", idx, debug_ivec4(&src_state->ps_consts_i[idx]));
755
756 stateblock->state.ps_consts_i[idx] = src_state->ps_consts_i[idx];
757 }
758
759 /* Pixel shader boolean constants. */
760 for (i = 0; i < stateblock->num_contained_ps_consts_b; ++i)
761 {
762 unsigned int idx = stateblock->contained_ps_consts_b[i];
763 TRACE("Setting ps_consts_b[%u] to %s.\n",
764 idx, src_state->ps_consts_b[idx] ? "TRUE" : "FALSE");
765
766 stateblock->state.ps_consts_b[idx] = src_state->ps_consts_b[idx];
767 }
768
769 /* Others + Render & Texture */
770 for (i = 0; i < stateblock->num_contained_transform_states; ++i)
771 {
773
774 TRACE("Updating transform %#x.\n", transform);
775
776 stateblock->state.transforms[transform] = src_state->transforms[transform];
777 }
778
779 if (stateblock->changed.indices
780 && ((stateblock->state.index_buffer != src_state->index_buffer)
781 || (stateblock->state.base_vertex_index != src_state->base_vertex_index)
782 || (stateblock->state.index_format != src_state->index_format)
783 || (stateblock->state.index_offset != src_state->index_offset)))
784 {
785 TRACE("Updating index buffer to %p, base vertex index to %d.\n",
786 src_state->index_buffer, src_state->base_vertex_index);
787
788 if (src_state->index_buffer)
790 if (stateblock->state.index_buffer)
791 wined3d_buffer_decref(stateblock->state.index_buffer);
792 stateblock->state.index_buffer = src_state->index_buffer;
793 stateblock->state.base_vertex_index = src_state->base_vertex_index;
794 stateblock->state.index_format = src_state->index_format;
795 stateblock->state.index_offset = src_state->index_offset;
796 }
797
798 if (stateblock->changed.vertexDecl && stateblock->state.vertex_declaration != src_state->vertex_declaration)
799 {
800 TRACE("Updating vertex declaration from %p to %p.\n",
801 stateblock->state.vertex_declaration, src_state->vertex_declaration);
802
803 if (src_state->vertex_declaration)
805 if (stateblock->state.vertex_declaration)
806 wined3d_vertex_declaration_decref(stateblock->state.vertex_declaration);
807 stateblock->state.vertex_declaration = src_state->vertex_declaration;
808 }
809
810 if (stateblock->changed.material
811 && memcmp(&src_state->material, &stateblock->state.material, sizeof(stateblock->state.material)))
812 {
813 TRACE("Updating material.\n");
814
815 stateblock->state.material = src_state->material;
816 }
817
818 if (stateblock->changed.viewport
819 && memcmp(&src_state->viewport, &stateblock->state.viewport, sizeof(stateblock->state.viewport)))
820 {
821 TRACE("Updating viewport.\n");
822
823 stateblock->state.viewport = src_state->viewport;
824 }
825
826 if (stateblock->changed.scissorRect && memcmp(&src_state->scissor_rect,
827 &stateblock->state.scissor_rect, sizeof(stateblock->state.scissor_rect)))
828 {
829 TRACE("Updating scissor rect.\n");
830
831 stateblock->state.scissor_rect = src_state->scissor_rect;
832 }
833
834 map = stateblock->changed.streamSource;
835 for (i = 0; map; map >>= 1, ++i)
836 {
837 if (!(map & 1)) continue;
838
839 if (stateblock->state.streams[i].stride != src_state->streams[i].stride
840 || stateblock->state.streams[i].buffer != src_state->streams[i].buffer)
841 {
842 TRACE("Updating stream source %u to %p, stride to %u.\n",
843 i, src_state->streams[i].buffer,
844 src_state->streams[i].stride);
845
846 stateblock->state.streams[i].stride = src_state->streams[i].stride;
847 if (src_state->streams[i].buffer)
848 wined3d_buffer_incref(src_state->streams[i].buffer);
849 if (stateblock->state.streams[i].buffer)
850 wined3d_buffer_decref(stateblock->state.streams[i].buffer);
851 stateblock->state.streams[i].buffer = src_state->streams[i].buffer;
852 }
853 }
854
855 map = stateblock->changed.streamFreq;
856 for (i = 0; map; map >>= 1, ++i)
857 {
858 if (!(map & 1)) continue;
859
860 if (stateblock->state.streams[i].frequency != src_state->streams[i].frequency
861 || stateblock->state.streams[i].flags != src_state->streams[i].flags)
862 {
863 TRACE("Updating stream frequency %u to %u flags to %#x.\n",
864 i, src_state->streams[i].frequency, src_state->streams[i].flags);
865
866 stateblock->state.streams[i].frequency = src_state->streams[i].frequency;
867 stateblock->state.streams[i].flags = src_state->streams[i].flags;
868 }
869 }
870
871 map = stateblock->changed.clipplane;
872 for (i = 0; map; map >>= 1, ++i)
873 {
874 if (!(map & 1)) continue;
875
876 if (memcmp(&stateblock->state.clip_planes[i], &src_state->clip_planes[i], sizeof(src_state->clip_planes[i])))
877 {
878 TRACE("Updating clipplane %u.\n", i);
879 stateblock->state.clip_planes[i] = src_state->clip_planes[i];
880 }
881 }
882
883 /* Render */
884 for (i = 0; i < stateblock->num_contained_render_states; ++i)
885 {
886 enum wined3d_render_state rs = stateblock->contained_render_states[i];
887
888 TRACE("Updating render state %#x to %u.\n", rs, src_state->render_states[rs]);
889
890 stateblock->state.render_states[rs] = src_state->render_states[rs];
891 }
892
893 /* Texture states */
894 for (i = 0; i < stateblock->num_contained_tss_states; ++i)
895 {
896 DWORD stage = stateblock->contained_tss_states[i].stage;
897 DWORD state = stateblock->contained_tss_states[i].state;
898
899 TRACE("Updating texturestage state %u, %u to %#x (was %#x).\n", stage, state,
900 src_state->texture_states[stage][state], stateblock->state.texture_states[stage][state]);
901
902 stateblock->state.texture_states[stage][state] = src_state->texture_states[stage][state];
903 }
904
905 /* Samplers */
906 map = stateblock->changed.textures;
907 for (i = 0; map; map >>= 1, ++i)
908 {
909 if (!(map & 1)) continue;
910
911 TRACE("Updating texture %u to %p (was %p).\n",
912 i, src_state->textures[i], stateblock->state.textures[i]);
913
914 if (src_state->textures[i])
915 wined3d_texture_incref(src_state->textures[i]);
916 if (stateblock->state.textures[i])
917 wined3d_texture_decref(stateblock->state.textures[i]);
918 stateblock->state.textures[i] = src_state->textures[i];
919 }
920
921 for (i = 0; i < stateblock->num_contained_sampler_states; ++i)
922 {
923 DWORD stage = stateblock->contained_sampler_states[i].stage;
924 DWORD state = stateblock->contained_sampler_states[i].state;
925
926 TRACE("Updating sampler state %u, %u to %#x (was %#x).\n", stage, state,
927 src_state->sampler_states[stage][state], stateblock->state.sampler_states[stage][state]);
928
929 stateblock->state.sampler_states[stage][state] = src_state->sampler_states[stage][state];
930 }
931
932 if (stateblock->changed.pixelShader && stateblock->state.shader[WINED3D_SHADER_TYPE_PIXEL]
933 != src_state->shader[WINED3D_SHADER_TYPE_PIXEL])
934 {
935 if (src_state->shader[WINED3D_SHADER_TYPE_PIXEL])
937 if (stateblock->state.shader[WINED3D_SHADER_TYPE_PIXEL])
939 stateblock->state.shader[WINED3D_SHADER_TYPE_PIXEL] = src_state->shader[WINED3D_SHADER_TYPE_PIXEL];
940 }
941
942 wined3d_state_record_lights(&stateblock->state, src_state);
943
944 TRACE("Capture done.\n");
945}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ULONG CDECL wined3d_buffer_incref(struct wined3d_buffer *buffer)
Definition: buffer.c:525
ULONG CDECL wined3d_shader_incref(struct wined3d_shader *shader)
Definition: shader.c:3339
ULONG CDECL wined3d_texture_incref(struct wined3d_texture *texture)
Definition: texture.c:994
const char * debug_ivec4(const struct wined3d_ivec4 *v)
Definition: utils.c:3956
const char * debug_vec4(const struct wined3d_vec4 *v)
Definition: utils.c:3972
GLuint GLenum GLenum transform
Definition: glext.h:9407
enum wined3d_format_id index_format
struct wined3d_vertex_declaration * vertex_declaration
struct wined3d_matrix transforms[HIGHEST_TRANSFORMSTATE+1]
BOOL ps_consts_b[WINED3D_MAX_CONSTS_B]
DWORD texture_states[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE+1]
struct wined3d_texture * textures[MAX_COMBINED_SAMPLERS]
struct wined3d_material material
struct wined3d_viewport viewport
struct wined3d_shader * shader[WINED3D_SHADER_TYPE_COUNT]
struct wined3d_ivec4 ps_consts_i[WINED3D_MAX_CONSTS_I]
struct wined3d_buffer * index_buffer
struct wined3d_stream_state streams[MAX_STREAMS+1]
BOOL vs_consts_b[WINED3D_MAX_CONSTS_B]
DWORD render_states[WINEHIGHEST_RENDER_STATE+1]
unsigned int index_offset
struct wined3d_vec4 ps_consts_f[WINED3D_MAX_PS_CONSTS_F]
struct wined3d_ivec4 vs_consts_i[WINED3D_MAX_CONSTS_I]
struct wined3d_vec4 vs_consts_f[WINED3D_MAX_VS_CONSTS_F]
struct wined3d_vec4 clip_planes[MAX_CLIP_DISTANCES]
DWORD sampler_states[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE+1]
static void wined3d_state_record_lights(struct wined3d_state *dst_state, const struct wined3d_state *src_state)
Definition: stateblock.c:627
ULONG CDECL wined3d_vertex_declaration_incref(struct wined3d_vertex_declaration *declaration)
wined3d_render_state
Definition: wined3d.h:264
wined3d_transform_state
Definition: wined3d.h:647

Referenced by d3d8_device_CaptureStateBlock(), d3d9_stateblock_Capture(), d3d_device7_CaptureStateBlock(), ddraw_set_cooperative_level(), and stateblock_init().

◆ wined3d_stateblock_create()

HRESULT CDECL wined3d_stateblock_create ( struct wined3d_device device,
enum wined3d_stateblock_type  type,
struct wined3d_stateblock **  stateblock 
)

Definition at line 1372 of file stateblock.c.

1374{
1375 struct wined3d_stateblock *object;
1376 HRESULT hr;
1377
1378 TRACE("device %p, type %#x, stateblock %p.\n",
1379 device, type, stateblock);
1380
1381 if (!(object = heap_alloc_zero(sizeof(*object))))
1382 return E_OUTOFMEMORY;
1383
1384 hr = stateblock_init(object, device, type);
1385 if (FAILED(hr))
1386 {
1387 WARN("Failed to initialize stateblock, hr %#x.\n", hr);
1388 heap_free(object);
1389 return hr;
1390 }
1391
1392 TRACE("Created stateblock %p.\n", object);
1393 *stateblock = object;
1394
1395 return WINED3D_OK;
1396}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hr
Definition: shlfolder.c:183
static HRESULT stateblock_init(struct wined3d_stateblock *stateblock, struct wined3d_device *device, enum wined3d_stateblock_type type)
Definition: stateblock.c:1328

Referenced by d3d8_device_CreateStateBlock(), d3d_device7_CreateStateBlock(), ddraw_set_cooperative_level(), stateblock_init(), and wined3d_device_begin_stateblock().

◆ wined3d_stateblock_decref()

ULONG CDECL wined3d_stateblock_decref ( struct wined3d_stateblock stateblock)

Definition at line 552 of file stateblock.c.

553{
554 ULONG refcount = InterlockedDecrement(&stateblock->ref);
555
556 TRACE("%p decreasing refcount to %u\n", stateblock, refcount);
557
558 if (!refcount)
559 {
560 state_cleanup(&stateblock->state);
561 heap_free(stateblock);
562 }
563
564 return refcount;
565}
#define InterlockedDecrement
Definition: armddk.h:52
uint32_t ULONG
Definition: typedefs.h:59
void state_cleanup(struct wined3d_state *state)
Definition: stateblock.c:528

Referenced by d3d8_device_CreateStateBlock(), d3d8_device_DeleteStateBlock(), d3d8_device_EndStateBlock(), d3d9_device_EndStateBlock(), d3d9_stateblock_Release(), d3d_device7_CreateStateBlock(), d3d_device7_DeleteStateBlock(), d3d_device7_EndStateBlock(), ddraw_set_cooperative_level(), wined3d_device_decref(), and wined3d_device_reset().

◆ wined3d_stateblock_incref()

ULONG CDECL wined3d_stateblock_incref ( struct wined3d_stateblock stateblock)

Definition at line 420 of file stateblock.c.

421{
422 ULONG refcount = InterlockedIncrement(&stateblock->ref);
423
424 TRACE("%p increasing refcount to %u.\n", stateblock, refcount);
425
426 return refcount;
427}
#define InterlockedIncrement
Definition: armddk.h:53

Variable Documentation

◆ pixel_states_render

const DWORD pixel_states_render[]
static

Definition at line 31 of file stateblock.c.

Referenced by stateblock_savedstates_set_pixel().

◆ pixel_states_sampler

◆ pixel_states_texture

◆ vertex_states_render

const DWORD vertex_states_render[]
static

Definition at line 137 of file stateblock.c.

Referenced by stateblock_savedstates_set_vertex().

◆ vertex_states_sampler

const DWORD vertex_states_sampler[]
static
Initial value:

Definition at line 192 of file stateblock.c.

Referenced by stateblock_savedstates_set_vertex().

◆ vertex_states_texture

const DWORD vertex_states_texture[]
static