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

Go to the source code of this file.

Classes

struct  wined3d_saved_states
 
struct  stage_state
 
struct  wined3d_stateblock
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d)
 
 WINE_DECLARE_DEBUG_CHANNEL (winediag)
 
static void transpose_matrix (struct wined3d_matrix *out, const struct wined3d_matrix *m)
 
static void stateblock_set_all_bits (uint32_t *map, UINT map_size)
 
static void stateblock_savedstates_set_all (struct wined3d_saved_states *states, DWORD vs_consts, DWORD ps_consts)
 
void CDECL wined3d_stateblock_primary_dirtify_all_states (struct wined3d_device *device, struct wined3d_stateblock *stateblock)
 
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 CDECL wined3d_stateblock_init_contained_states (struct wined3d_stateblock *stateblock)
 
static void stateblock_init_lights (struct wined3d_stateblock *stateblock, const struct rb_tree *src_tree)
 
ULONG CDECL wined3d_stateblock_incref (struct wined3d_stateblock *stateblock)
 
void state_unbind_resources (struct wined3d_state *state)
 
static void wined3d_stateblock_state_cleanup (struct wined3d_stateblock_state *state)
 
void state_cleanup (struct wined3d_state *state)
 
ULONG CDECL wined3d_stateblock_decref (struct wined3d_stateblock *stateblock)
 
struct wined3d_light_info * wined3d_light_state_get_light (const struct wined3d_light_state *state, unsigned int idx)
 
static void set_light_changed (struct wined3d_stateblock *stateblock, struct wined3d_light_info *light_info)
 
static HRESULT wined3d_light_state_set_light (struct wined3d_light_state *state, unsigned int light_idx, const struct wined3d_light *params, struct wined3d_light_info **light_info)
 
bool wined3d_light_state_enable_light (struct wined3d_light_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_light_state *dst_state, const struct wined3d_light_state *src_state)
 
void CDECL wined3d_stateblock_capture (struct wined3d_stateblock *stateblock, const struct wined3d_stateblock *device_state)
 
void CDECL wined3d_stateblock_apply (const struct wined3d_stateblock *stateblock, struct wined3d_stateblock *device_state)
 
void CDECL wined3d_stateblock_set_vertex_shader (struct wined3d_stateblock *stateblock, struct wined3d_shader *shader)
 
static void wined3d_bitmap_set_bits (uint32_t *bitmap, unsigned int start, unsigned int count)
 
HRESULT CDECL wined3d_stateblock_set_vs_consts_f (struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants)
 
HRESULT CDECL wined3d_stateblock_set_vs_consts_i (struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants)
 
HRESULT CDECL wined3d_stateblock_set_vs_consts_b (struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, const BOOL *constants)
 
HRESULT CDECL wined3d_stateblock_get_vs_consts_f (struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, struct wined3d_vec4 *constants)
 
HRESULT CDECL wined3d_stateblock_get_vs_consts_i (struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, struct wined3d_ivec4 *constants)
 
HRESULT CDECL wined3d_stateblock_get_vs_consts_b (struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, BOOL *constants)
 
void CDECL wined3d_stateblock_set_pixel_shader (struct wined3d_stateblock *stateblock, struct wined3d_shader *shader)
 
HRESULT CDECL wined3d_stateblock_set_ps_consts_f (struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants)
 
HRESULT CDECL wined3d_stateblock_set_ps_consts_i (struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants)
 
HRESULT CDECL wined3d_stateblock_set_ps_consts_b (struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, const BOOL *constants)
 
HRESULT CDECL wined3d_stateblock_get_ps_consts_f (struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, struct wined3d_vec4 *constants)
 
HRESULT CDECL wined3d_stateblock_get_ps_consts_i (struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, struct wined3d_ivec4 *constants)
 
HRESULT CDECL wined3d_stateblock_get_ps_consts_b (struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, BOOL *constants)
 
void CDECL wined3d_stateblock_set_vertex_declaration (struct wined3d_stateblock *stateblock, struct wined3d_vertex_declaration *declaration)
 
void CDECL wined3d_stateblock_set_render_state (struct wined3d_stateblock *stateblock, enum wined3d_render_state state, unsigned int value)
 
void CDECL wined3d_stateblock_set_sampler_state (struct wined3d_stateblock *stateblock, UINT sampler_idx, enum wined3d_sampler_state state, unsigned int value)
 
void CDECL wined3d_stateblock_set_texture_stage_state (struct wined3d_stateblock *stateblock, UINT stage, enum wined3d_texture_stage_state state, unsigned int value)
 
static bool texture_binding_might_invalidate_fs_settings (const struct wined3d_stateblock *stateblock, const struct wined3d_texture *texture, const struct wined3d_texture *prev, unsigned int stage)
 
void CDECL wined3d_stateblock_set_texture (struct wined3d_stateblock *stateblock, UINT stage, struct wined3d_texture *texture)
 
void CDECL wined3d_stateblock_set_transform (struct wined3d_stateblock *stateblock, enum wined3d_transform_state d3dts, const struct wined3d_matrix *matrix)
 
void CDECL wined3d_stateblock_multiply_transform (struct wined3d_stateblock *stateblock, enum wined3d_transform_state d3dts, const struct wined3d_matrix *matrix)
 
HRESULT CDECL wined3d_stateblock_set_clip_plane (struct wined3d_stateblock *stateblock, UINT plane_idx, const struct wined3d_vec4 *plane)
 
void CDECL wined3d_stateblock_set_material (struct wined3d_stateblock *stateblock, const struct wined3d_material *material)
 
void CDECL wined3d_stateblock_set_viewport (struct wined3d_stateblock *stateblock, const struct wined3d_viewport *viewport)
 
void CDECL wined3d_stateblock_set_scissor_rect (struct wined3d_stateblock *stateblock, const RECT *rect)
 
void CDECL wined3d_stateblock_set_index_buffer (struct wined3d_stateblock *stateblock, struct wined3d_buffer *buffer, enum wined3d_format_id format_id)
 
void CDECL wined3d_stateblock_set_base_vertex_index (struct wined3d_stateblock *stateblock, INT base_index)
 
HRESULT CDECL wined3d_stateblock_set_stream_source (struct wined3d_stateblock *stateblock, UINT stream_idx, struct wined3d_buffer *buffer, UINT offset, UINT stride)
 
HRESULT CDECL wined3d_stateblock_set_stream_source_freq (struct wined3d_stateblock *stateblock, UINT stream_idx, UINT divider)
 
HRESULT CDECL wined3d_stateblock_set_light (struct wined3d_stateblock *stateblock, UINT light_idx, const struct wined3d_light *light)
 
HRESULT CDECL wined3d_stateblock_set_light_enable (struct wined3d_stateblock *stateblock, UINT light_idx, BOOL enable)
 
const struct wined3d_stateblock_state *CDECL wined3d_stateblock_get_state (const struct wined3d_stateblock *stateblock)
 
HRESULT CDECL wined3d_stateblock_get_light (const struct wined3d_stateblock *stateblock, UINT light_idx, struct wined3d_light *light, BOOL *enabled)
 
static void init_default_render_states (unsigned int rs[WINEHIGHEST_RENDER_STATE+1], const struct wined3d_d3d_info *d3d_info)
 
static void init_default_texture_state (unsigned int i, uint32_t stage[WINED3D_HIGHEST_TEXTURE_STATE+1])
 
static void init_default_sampler_states (uint32_t states[WINED3D_MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE+1])
 
static void state_init_default (struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info)
 
static int lights_compare (const void *key, const struct rb_entry *entry)
 
void state_init (struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, uint32_t flags, enum wined3d_feature_level feature_level)
 
static bool wined3d_select_feature_level (const struct wined3d_adapter *adapter, const enum wined3d_feature_level *levels, unsigned int level_count, enum wined3d_feature_level *selected_level)
 
HRESULT CDECL wined3d_state_create (struct wined3d_device *device, const enum wined3d_feature_level *levels, unsigned int level_count, struct wined3d_state **state)
 
enum wined3d_feature_level CDECL wined3d_state_get_feature_level (const struct wined3d_state *state)
 
void CDECL wined3d_state_destroy (struct wined3d_state *state)
 
static void stateblock_state_init_default (struct wined3d_stateblock_state *state, const struct wined3d_d3d_info *d3d_info)
 
static void wined3d_stateblock_state_init (struct wined3d_stateblock_state *state, const struct wined3d_device *device, uint32_t flags)
 
static void wined3d_stateblock_invalidate_initial_states (struct wined3d_stateblock *stateblock)
 
static HRESULT stateblock_init (struct wined3d_stateblock *stateblock, const struct wined3d_stateblock *device_state, struct wined3d_device *device, enum wined3d_stateblock_type type)
 
HRESULT CDECL wined3d_stateblock_create (struct wined3d_device *device, const struct wined3d_stateblock *device_state, enum wined3d_stateblock_type type, struct wined3d_stateblock **stateblock)
 
void CDECL wined3d_stateblock_reset (struct wined3d_stateblock *stateblock)
 
static void wined3d_device_set_base_vertex_index (struct wined3d_device *device, int base_index)
 
static void wined3d_device_set_vs_consts_b (struct wined3d_device *device, unsigned int start_idx, unsigned int count, const BOOL *constants)
 
static void wined3d_device_set_vs_consts_i (struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants)
 
static void wined3d_device_set_vs_consts_f (struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants)
 
static void wined3d_device_set_ps_consts_b (struct wined3d_device *device, unsigned int start_idx, unsigned int count, const BOOL *constants)
 
static void wined3d_device_set_ps_consts_i (struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants)
 
static void wined3d_device_set_ps_consts_f (struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants)
 
static void wined3d_device_context_set_light (struct wined3d_device_context *context, unsigned int light_idx, const struct wined3d_light *light)
 
static void wined3d_device_set_light_enable (struct wined3d_device *device, unsigned int light_idx, bool enable)
 
static void wined3d_device_set_clip_plane (struct wined3d_device *device, unsigned int plane_idx, const struct wined3d_vec4 *plane)
 
static void resolve_depth_buffer (struct wined3d_device *device)
 
static void wined3d_device_set_render_state (struct wined3d_device *device, enum wined3d_render_state state, unsigned int value)
 
static void wined3d_device_set_texture_stage_state (struct wined3d_device *device, unsigned int stage, enum wined3d_texture_stage_state state, uint32_t value)
 
static void wined3d_device_set_texture (struct wined3d_device *device, unsigned int stage, struct wined3d_texture *texture)
 
static void wined3d_device_set_transform (struct wined3d_device *device, enum wined3d_transform_state state, const struct wined3d_matrix *matrix)
 
static enum wined3d_texture_address get_texture_address_mode (const struct wined3d_texture *texture, enum wined3d_texture_address t)
 
static void sampler_desc_from_sampler_states (struct wined3d_sampler_desc *desc, const uint32_t *sampler_states, const struct wined3d_texture *texture)
 
void CDECL wined3d_stateblock_apply_clear_state (struct wined3d_stateblock *stateblock, struct wined3d_device *device)
 
static struct wined3d_shader * get_ffp_vertex_shader (struct wined3d_device *device, const struct wined3d_state *state)
 
static struct wined3d_shader * get_ffp_pixel_shader (struct wined3d_device *device, const struct wined3d_state *state)
 
static void bind_push_constant_buffer (struct wined3d_device *device, enum wined3d_push_constants type, enum wined3d_shader_type shader_type, unsigned int shader_binding)
 
void CDECL wined3d_device_apply_stateblock (struct wined3d_device *device, struct wined3d_stateblock *stateblock)
 
unsigned int CDECL wined3d_stateblock_set_texture_lod (struct wined3d_stateblock *stateblock, struct wined3d_texture *texture, unsigned int lod)
 
void CDECL wined3d_stateblock_texture_changed (struct wined3d_stateblock *stateblock, const struct wined3d_texture *texture)
 
void CDECL wined3d_stateblock_depth_buffer_changed (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

◆ bind_push_constant_buffer()

static void bind_push_constant_buffer ( struct wined3d_device *  device,
enum wined3d_push_constants  type,
enum wined3d_shader_type  shader_type,
unsigned int  shader_binding 
)
static

Definition at line 3024 of file stateblock.c.

3026{
3028
3029 if (!device->adapter->d3d_info.gpu_push_constants || !device->push_constants[type])
3030 return;
3031
3032 state.buffer = device->push_constants[type];
3033 state.offset = 0;
3034 state.size = device->push_constants[type]->resource.size,
3036}
static int state
Definition: maze.c:121
void CDECL wined3d_device_context_set_constant_buffers(struct wined3d_device_context *context, enum wined3d_shader_type type, unsigned int start_idx, unsigned int count, const struct wined3d_constant_buffer_state *buffers)
Definition: device.c:2015
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
Definition: devices.h:37
uint64_t size
Definition: devices.h:44

Referenced by wined3d_device_apply_stateblock().

◆ get_ffp_pixel_shader()

static struct wined3d_shader * get_ffp_pixel_shader ( struct wined3d_device *  device,
const struct wined3d_state *  state 
)
static

Definition at line 2999 of file stateblock.c.

3000{
3002 const struct ffp_frag_desc *desc;
3003 struct wined3d_ffp_ps *ps;
3004
3005 wined3d_ffp_get_fs_settings(state, &device->adapter->d3d_info, &settings);
3006
3007 if ((desc = find_ffp_frag_shader(&device->ffp_pixel_shaders, &settings)))
3008 return CONTAINING_RECORD(desc, struct wined3d_ffp_ps, entry)->shader;
3009
3010 if (!(ps = malloc(sizeof(*ps))))
3011 return NULL;
3012
3013 ps->entry.settings = settings;
3015 {
3016 free(ps);
3017 return NULL;
3018 }
3019 add_ffp_frag_shader(&device->ffp_pixel_shaders, &ps->entry);
3020
3021 return ps->shader;
3022}
struct mke2fs_defaults settings[]
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
HRESULT wined3d_shader_create_ffp_ps(struct wined3d_device *device, const struct ffp_frag_settings *settings, struct wined3d_shader **shader)
Definition: shader.c:3370
const struct ffp_frag_desc * find_ffp_frag_shader(const struct wine_rb_tree *fragment_shaders, const struct ffp_frag_settings *settings)
Definition: utils.c:6419
void wined3d_ffp_get_fs_settings(const struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, struct ffp_frag_settings *settings)
Definition: utils.c:6141
void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *desc)
Definition: utils.c:6426
#define FAILED(hr)
Definition: intsafe.h:51
uint32_t entry
Definition: isohybrid.c:63
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
struct ffp_frag_desc entry
struct wined3d_shader * shader
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by wined3d_device_apply_stateblock().

◆ get_ffp_vertex_shader()

static struct wined3d_shader * get_ffp_vertex_shader ( struct wined3d_device *  device,
const struct wined3d_state *  state 
)
static

Definition at line 2965 of file stateblock.c.

2966{
2967 static const struct wined3d_stream_info dummy_stream_info;
2969 const struct wine_rb_entry *entry;
2970 struct wined3d_ffp_vs *vs;
2971
2972 /* XXX: wined3d_ffp_get_vs_settings() only needs the stream info for the
2973 * swizzle map, which the HLSL pipeline doesn't use (it will be computed and
2974 * used later as part of struct vs_compile_args).
2975 *
2976 * This is nevertheless janky, and we'd like to get rid of it. Eventually
2977 * once the HLSL backend is used everywhere, we can get rid of the swizzle
2978 * map from wined3d_ffp_vs_settings. */
2979 wined3d_ffp_get_vs_settings(state, &dummy_stream_info, &device->adapter->d3d_info, &settings);
2980
2981 if ((entry = wine_rb_get(&device->ffp_vertex_shaders, &settings)))
2982 return WINE_RB_ENTRY_VALUE(entry, struct wined3d_ffp_vs, entry.entry)->shader;
2983
2984 if (!(vs = malloc(sizeof(*vs))))
2985 return NULL;
2986
2987 vs->entry.settings = settings;
2989 {
2990 free(vs);
2991 return NULL;
2992 }
2993 if (wine_rb_put(&device->ffp_vertex_shaders, &vs->entry.settings, &vs->entry.entry) == -1)
2994 ERR("Failed to insert FFP vertex shader.\n");
2995
2996 return vs->shader;
2997}
#define ERR(fmt,...)
Definition: precomp.h:57
HRESULT wined3d_shader_create_ffp_vs(struct wined3d_device *device, const struct wined3d_ffp_vs_settings *settings, struct wined3d_shader **shader)
Definition: shader.c:3345
void wined3d_ffp_get_vs_settings(const struct wined3d_state *state, const struct wined3d_stream_info *si, const struct wined3d_d3d_info *d3d_info, struct wined3d_ffp_vs_settings *settings)
Definition: utils.c:6444
static vector_t * vs
Definition: server.c:146
#define wine_rb_entry
Definition: rbtree.h:404
#define WINE_RB_ENTRY_VALUE
Definition: rbtree.h:414
#define wine_rb_put
Definition: rbtree.h:410
#define wine_rb_get
Definition: rbtree.h:409

Referenced by wined3d_device_apply_stateblock().

◆ get_texture_address_mode()

static enum wined3d_texture_address get_texture_address_mode ( const struct wined3d_texture *  texture,
enum wined3d_texture_address  t 
)
static

Definition at line 2833 of file stateblock.c.

2835{
2836 if (t < WINED3D_TADDRESS_WRAP || t > WINED3D_TADDRESS_MIRROR_ONCE)
2837 {
2838 FIXME("Unrecognized or unsupported texture address mode %#x.\n", t);
2839 return WINED3D_TADDRESS_WRAP;
2840 }
2841
2842 /* Cubemaps are always set to clamp, regardless of the sampler state. */
2843 if ((texture->resource.usage & WINED3DUSAGE_LEGACY_CUBEMAP)
2846
2847 return t;
2848}
#define FIXME(fmt,...)
Definition: precomp.h:53
GLdouble GLdouble t
Definition: gl.h:2047
GLenum GLuint texture
Definition: glext.h:6295
#define WINED3DUSAGE_LEGACY_CUBEMAP
Definition: wined3d.h:934
@ WINED3D_TADDRESS_MIRROR_ONCE
Definition: wined3d.h:662
@ WINED3D_TADDRESS_WRAP
Definition: wined3d.h:658
@ WINED3D_TADDRESS_CLAMP
Definition: wined3d.h:660
#define WINED3D_TEXTURE_COND_NP2

Referenced by sampler_desc_from_sampler_states().

◆ init_default_render_states()

static void init_default_render_states ( unsigned int  rs[WINEHIGHEST_RENDER_STATE+1],
const struct wined3d_d3d_info *  d3d_info 
)
static

Definition at line 2084 of file stateblock.c.

2085{
2086 union
2087 {
2088 struct wined3d_line_pattern lp;
2089 DWORD d;
2090 } lp;
2091 union
2092 {
2093 float f;
2094 DWORD d;
2095 } tmpfloat;
2096
2100 lp.lp.repeat_factor = 0;
2101 lp.lp.line_pattern = 0;
2102 rs[WINED3D_RS_LINEPATTERN] = lp.d;
2111 rs[WINED3D_RS_ALPHAREF] = 0;
2116 rs[WINED3D_RS_ZVISIBLE] = 0;
2117 rs[WINED3D_RS_FOGCOLOR] = 0;
2119 tmpfloat.f = 0.0f;
2120 rs[WINED3D_RS_FOGSTART] = tmpfloat.d;
2121 tmpfloat.f = 1.0f;
2122 rs[WINED3D_RS_FOGEND] = tmpfloat.d;
2123 tmpfloat.f = 1.0f;
2124 rs[WINED3D_RS_FOGDENSITY] = tmpfloat.d;
2130 rs[WINED3D_RS_STENCILREF] = 0;
2131 rs[WINED3D_RS_STENCILMASK] = 0xffffffff;
2133 rs[WINED3D_RS_STENCILWRITEMASK] = 0xffffffff;
2134 rs[WINED3D_RS_TEXTUREFACTOR] = 0xffffffff;
2135 rs[WINED3D_RS_WRAP0] = 0;
2136 rs[WINED3D_RS_WRAP1] = 0;
2137 rs[WINED3D_RS_WRAP2] = 0;
2138 rs[WINED3D_RS_WRAP3] = 0;
2139 rs[WINED3D_RS_WRAP4] = 0;
2140 rs[WINED3D_RS_WRAP5] = 0;
2141 rs[WINED3D_RS_WRAP6] = 0;
2142 rs[WINED3D_RS_WRAP7] = 0;
2145 rs[WINED3D_RS_AMBIENT] = 0;
2157 tmpfloat.f = 1.0f;
2158 rs[WINED3D_RS_POINTSIZE] = tmpfloat.d;
2159 tmpfloat.f = 1.0f;
2160 rs[WINED3D_RS_POINTSIZE_MIN] = tmpfloat.d;
2163 tmpfloat.f = 1.0f;
2164 rs[WINED3D_RS_POINTSCALE_A] = tmpfloat.d;
2165 tmpfloat.f = 0.0f;
2166 rs[WINED3D_RS_POINTSCALE_B] = tmpfloat.d;
2167 tmpfloat.f = 0.0f;
2168 rs[WINED3D_RS_POINTSCALE_C] = tmpfloat.d;
2170 rs[WINED3D_RS_MULTISAMPLEMASK] = 0xffffffff;
2172 tmpfloat.f = 1.0f;
2173 rs[WINED3D_RS_PATCHSEGMENTS] = tmpfloat.d;
2174 rs[WINED3D_RS_DEBUGMONITORTOKEN] = 0xbaadcafe;
2175 tmpfloat.f = d3d_info->limits.pointsize_max;
2176 rs[WINED3D_RS_POINTSIZE_MAX] = tmpfloat.d;
2178 rs[WINED3D_RS_COLORWRITEENABLE] = 0x0000000f;
2179 tmpfloat.f = 0.0f;
2180 rs[WINED3D_RS_TWEENFACTOR] = tmpfloat.d;
2184 /* states new in d3d9 */
2187 tmpfloat.f = 1.0f;
2188 rs[WINED3D_RS_MINTESSELLATIONLEVEL] = tmpfloat.d;
2189 rs[WINED3D_RS_MAXTESSELLATIONLEVEL] = tmpfloat.d;
2191 tmpfloat.f = 0.0f;
2192 rs[WINED3D_RS_ADAPTIVETESS_X] = tmpfloat.d;
2193 rs[WINED3D_RS_ADAPTIVETESS_Y] = tmpfloat.d;
2194 tmpfloat.f = 1.0f;
2195 rs[WINED3D_RS_ADAPTIVETESS_Z] = tmpfloat.d;
2196 tmpfloat.f = 0.0f;
2197 rs[WINED3D_RS_ADAPTIVETESS_W] = tmpfloat.d;
2204 rs[WINED3D_RS_COLORWRITEENABLE1] = 0x0000000f;
2205 rs[WINED3D_RS_COLORWRITEENABLE2] = 0x0000000f;
2206 rs[WINED3D_RS_COLORWRITEENABLE3] = 0x0000000f;
2207 rs[WINED3D_RS_BLENDFACTOR] = 0xffffffff;
2209 rs[WINED3D_RS_DEPTHBIAS] = 0;
2210 rs[WINED3D_RS_WRAP8] = 0;
2211 rs[WINED3D_RS_WRAP9] = 0;
2212 rs[WINED3D_RS_WRAP10] = 0;
2213 rs[WINED3D_RS_WRAP11] = 0;
2214 rs[WINED3D_RS_WRAP12] = 0;
2215 rs[WINED3D_RS_WRAP13] = 0;
2216 rs[WINED3D_RS_WRAP14] = 0;
2217 rs[WINED3D_RS_WRAP15] = 0;
2222}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
#define d
Definition: ke_i.h:81
#define f
Definition: ke_i.h:83
struct wined3d_d3d_limits limits
@ WINED3D_DEGREE_LINEAR
Definition: wined3d.h:115
@ WINED3D_DEGREE_CUBIC
Definition: wined3d.h:117
@ WINED3D_SHADE_GOURAUD
Definition: wined3d.h:489
@ WINED3D_BLEND_OP_ADD
Definition: wined3d.h:442
@ WINED3D_FOG_NONE
Definition: wined3d.h:480
@ WINED3D_RS_TEXTUREFACTOR
Definition: wined3d.h:337
@ WINED3D_RS_STENCILFAIL
Definition: wined3d.h:330
@ WINED3D_RS_NORMALDEGREE
Definition: wined3d.h:380
@ WINED3D_RS_WRAP8
Definition: wined3d.h:402
@ WINED3D_RS_LIGHTING
Definition: wined3d.h:347
@ WINED3D_RS_SOFTWAREVERTEXPROCESSING
Definition: wined3d.h:361
@ WINED3D_RS_COLORWRITEENABLE1
Definition: wined3d.h:396
@ WINED3D_RS_STENCILENABLE
Definition: wined3d.h:329
@ WINED3D_RS_COLORVERTEX
Definition: wined3d.h:351
@ WINED3D_RS_TWEENFACTOR
Definition: wined3d.h:377
@ WINED3D_RS_FOGCOLOR
Definition: wined3d.h:317
@ WINED3D_RS_WRAP4
Definition: wined3d.h:342
@ WINED3D_RS_WRAP15
Definition: wined3d.h:409
@ WINED3D_RS_ZENABLE
Definition: wined3d.h:293
@ WINED3D_RS_ANTIALIASEDLINEENABLE
Definition: wined3d.h:383
@ WINED3D_RS_SPECULARMATERIALSOURCE
Definition: wined3d.h:356
@ WINED3D_RS_STENCILPASS
Definition: wined3d.h:332
@ WINED3D_RS_WRAP13
Definition: wined3d.h:407
@ WINED3D_RS_DEBUGMONITORTOKEN
Definition: wined3d.h:373
@ WINED3D_RS_WRAP1
Definition: wined3d.h:339
@ WINED3D_RS_WRAP3
Definition: wined3d.h:341
@ WINED3D_RS_DEPTHBIAS
Definition: wined3d.h:401
@ WINED3D_RS_MAXTESSELLATIONLEVEL
Definition: wined3d.h:385
@ WINED3D_RS_DITHERENABLE
Definition: wined3d.h:309
@ WINED3D_RS_SHADEMODE
Definition: wined3d.h:295
@ WINED3D_RS_CULLMODE
Definition: wined3d.h:305
@ WINED3D_RS_BACK_STENCILPASS
Definition: wined3d.h:394
@ WINED3D_RS_PATCHEDGESTYLE
Definition: wined3d.h:371
@ WINED3D_RS_SCISSORTESTENABLE
Definition: wined3d.h:381
@ WINED3D_RS_LASTPIXEL
Definition: wined3d.h:302
@ WINED3D_RS_VERTEXBLEND
Definition: wined3d.h:359
@ WINED3D_RS_FOGEND
Definition: wined3d.h:320
@ WINED3D_RS_MINTESSELLATIONLEVEL
Definition: wined3d.h:384
@ WINED3D_RS_POINTSCALE_A
Definition: wined3d.h:366
@ WINED3D_RS_MULTISAMPLEMASK
Definition: wined3d.h:370
@ WINED3D_RS_BACK_STENCILFUNC
Definition: wined3d.h:395
@ WINED3D_RS_SRCBLEND
Definition: wined3d.h:303
@ WINED3D_RS_SRGBWRITEENABLE
Definition: wined3d.h:400
@ WINED3D_RS_RANGEFOGENABLE
Definition: wined3d.h:325
@ WINED3D_RS_POINTSIZE_MIN
Definition: wined3d.h:363
@ WINED3D_RS_ENABLEADAPTIVETESSELLATION
Definition: wined3d.h:390
@ WINED3D_RS_COLORWRITEENABLE3
Definition: wined3d.h:398
@ WINED3D_RS_ALPHABLENDENABLE
Definition: wined3d.h:310
@ WINED3D_RS_ADAPTIVETESS_X
Definition: wined3d.h:386
@ WINED3D_RS_LOCALVIEWER
Definition: wined3d.h:352
@ WINED3D_RS_ADAPTIVETESS_Z
Definition: wined3d.h:388
@ WINED3D_RS_WRAP0
Definition: wined3d.h:338
@ WINED3D_RS_STENCILMASK
Definition: wined3d.h:335
@ WINED3D_RS_BLENDOP
Definition: wined3d.h:378
@ WINED3D_RS_POINTSCALE_C
Definition: wined3d.h:368
@ WINED3D_RS_FOGSTART
Definition: wined3d.h:319
@ WINED3D_RS_STENCILFUNC
Definition: wined3d.h:333
@ WINED3D_RS_WRAP7
Definition: wined3d.h:345
@ WINED3D_RS_FOGTABLEMODE
Definition: wined3d.h:318
@ WINED3D_RS_POINTSIZE
Definition: wined3d.h:362
@ WINED3D_RS_POINTSIZE_MAX
Definition: wined3d.h:374
@ WINED3D_RS_ZWRITEENABLE
Definition: wined3d.h:300
@ WINED3D_RS_CLIPPLANEENABLE
Definition: wined3d.h:360
@ WINED3D_RS_DESTBLEND
Definition: wined3d.h:304
@ WINED3D_RS_AMBIENTMATERIALSOURCE
Definition: wined3d.h:357
@ WINED3D_RS_WRAP6
Definition: wined3d.h:344
@ WINED3D_RS_STENCILREF
Definition: wined3d.h:334
@ WINED3D_RS_FOGENABLE
Definition: wined3d.h:311
@ WINED3D_RS_POINTSPRITEENABLE
Definition: wined3d.h:364
@ WINED3D_RS_BACK_STENCILZFAIL
Definition: wined3d.h:393
@ WINED3D_RS_ZFUNC
Definition: wined3d.h:306
@ WINED3D_RS_POSITIONDEGREE
Definition: wined3d.h:379
@ WINED3D_RS_MULTISAMPLEANTIALIAS
Definition: wined3d.h:369
@ WINED3D_RS_BACK_STENCILFAIL
Definition: wined3d.h:392
@ WINED3D_RS_COLORWRITEENABLE
Definition: wined3d.h:376
@ WINED3D_RS_SLOPESCALEDEPTHBIAS
Definition: wined3d.h:382
@ WINED3D_RS_DIFFUSEMATERIALSOURCE
Definition: wined3d.h:355
@ WINED3D_RS_ALPHAREF
Definition: wined3d.h:307
@ WINED3D_RS_NORMALIZENORMALS
Definition: wined3d.h:353
@ WINED3D_RS_TWOSIDEDSTENCILMODE
Definition: wined3d.h:391
@ WINED3D_RS_EMISSIVEMATERIALSOURCE
Definition: wined3d.h:358
@ WINED3D_RS_PATCHSEGMENTS
Definition: wined3d.h:372
@ WINED3D_RS_SPECULARENABLE
Definition: wined3d.h:312
@ WINED3D_RS_WRAP2
Definition: wined3d.h:340
@ WINED3D_RS_ADAPTIVETESS_W
Definition: wined3d.h:389
@ WINED3D_RS_FILLMODE
Definition: wined3d.h:294
@ WINED3D_RS_CLIPPING
Definition: wined3d.h:346
@ WINED3D_RS_WRAP10
Definition: wined3d.h:404
@ WINED3D_RS_SRCBLENDALPHA
Definition: wined3d.h:411
@ WINED3D_RS_COLORWRITEENABLE2
Definition: wined3d.h:397
@ WINED3D_RS_POINTSCALEENABLE
Definition: wined3d.h:365
@ WINED3D_RS_WRAP14
Definition: wined3d.h:408
@ WINED3D_RS_FOGVERTEXMODE
Definition: wined3d.h:350
@ WINED3D_RS_STENCILWRITEMASK
Definition: wined3d.h:336
@ WINED3D_RS_AMBIENT
Definition: wined3d.h:349
@ WINED3D_RS_WRAP11
Definition: wined3d.h:405
@ WINED3D_RS_LINEPATTERN
Definition: wined3d.h:296
@ WINED3D_RS_ZVISIBLE
Definition: wined3d.h:313
@ WINED3D_RS_BLENDFACTOR
Definition: wined3d.h:399
@ WINED3D_RS_BLENDOPALPHA
Definition: wined3d.h:413
@ WINED3D_RS_DESTBLENDALPHA
Definition: wined3d.h:412
@ WINED3D_RS_FOGDENSITY
Definition: wined3d.h:321
@ WINED3D_RS_STENCILZFAIL
Definition: wined3d.h:331
@ WINED3D_RS_POINTSCALE_B
Definition: wined3d.h:367
@ WINED3D_RS_INDEXEDVERTEXBLENDENABLE
Definition: wined3d.h:375
@ WINED3D_RS_WRAP9
Definition: wined3d.h:403
@ WINED3D_RS_SEPARATEALPHABLENDENABLE
Definition: wined3d.h:410
@ WINED3D_RS_WRAP5
Definition: wined3d.h:343
@ WINED3D_RS_ADAPTIVETESS_Y
Definition: wined3d.h:387
@ WINED3D_RS_ALPHATESTENABLE
Definition: wined3d.h:301
@ WINED3D_RS_ALPHAFUNC
Definition: wined3d.h:308
@ WINED3D_RS_WRAP12
Definition: wined3d.h:406
@ WINED3D_PATCH_EDGE_DISCRETE
Definition: wined3d.h:528
@ WINED3D_MCS_COLOR2
Definition: wined3d.h:523
@ WINED3D_MCS_MATERIAL
Definition: wined3d.h:521
@ WINED3D_MCS_COLOR1
Definition: wined3d.h:522
@ WINED3D_CMP_ALWAYS
Definition: wined3d.h:468
@ WINED3D_CMP_LESSEQUAL
Definition: wined3d.h:464
@ WINED3D_VBF_DISABLE
Definition: wined3d.h:451
@ WINED3D_BLEND_ONE
Definition: wined3d.h:420
@ WINED3D_BLEND_ZERO
Definition: wined3d.h:419
@ WINED3D_ZB_TRUE
Definition: wined3d.h:474
@ WINED3D_FILL_SOLID
Definition: wined3d.h:497
@ WINED3D_STENCIL_OP_KEEP
Definition: wined3d.h:509
@ WINED3D_CULL_BACK
Definition: wined3d.h:504

Referenced by state_init_default(), and stateblock_state_init_default().

◆ init_default_sampler_states()

static void init_default_sampler_states ( uint32_t  states[WINED3D_MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE+1])
static

Definition at line 2245 of file stateblock.c.

2246{
2247 unsigned int i;
2248
2249 for (i = 0 ; i < WINED3D_MAX_COMBINED_SAMPLERS; ++i)
2250 {
2251 TRACE("Setting up default samplers states for sampler %u.\n", i);
2255 states[i][WINED3D_SAMP_BORDER_COLOR] = 0;
2259 states[i][WINED3D_SAMP_MIPMAP_LOD_BIAS] = 0;
2260 states[i][WINED3D_SAMP_MAX_MIP_LEVEL] = 0;
2261 states[i][WINED3D_SAMP_MAX_ANISOTROPY] = 1;
2262 states[i][WINED3D_SAMP_SRGB_TEXTURE] = 0;
2263 /* TODO: Indicates which element of a multielement texture to use. */
2264 states[i][WINED3D_SAMP_ELEMENT_INDEX] = 0;
2265 /* TODO: Vertex offset in the presampled displacement map. */
2266 states[i][WINED3D_SAMP_DMAP_OFFSET] = 0;
2267 }
2268}
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
#define TRACE(s)
Definition: solgame.cpp:4
#define WINED3D_MAX_COMBINED_SAMPLERS
Definition: wined3d.h:1600
@ WINED3D_SAMP_ELEMENT_INDEX
Definition: wined3d.h:566
@ WINED3D_SAMP_MAX_ANISOTROPY
Definition: wined3d.h:564
@ WINED3D_SAMP_MIPMAP_LOD_BIAS
Definition: wined3d.h:562
@ WINED3D_SAMP_MIN_FILTER
Definition: wined3d.h:560
@ WINED3D_SAMP_SRGB_TEXTURE
Definition: wined3d.h:565
@ WINED3D_SAMP_DMAP_OFFSET
Definition: wined3d.h:567
@ WINED3D_SAMP_MIP_FILTER
Definition: wined3d.h:561
@ WINED3D_SAMP_MAG_FILTER
Definition: wined3d.h:559
@ WINED3D_SAMP_BORDER_COLOR
Definition: wined3d.h:558
@ WINED3D_SAMP_ADDRESS_V
Definition: wined3d.h:556
@ WINED3D_SAMP_ADDRESS_U
Definition: wined3d.h:555
@ WINED3D_SAMP_ADDRESS_W
Definition: wined3d.h:557
@ WINED3D_SAMP_MAX_MIP_LEVEL
Definition: wined3d.h:563
@ WINED3D_TEXF_NONE
Definition: wined3d.h:705
@ WINED3D_TEXF_POINT
Definition: wined3d.h:706

Referenced by stateblock_state_init_default().

◆ init_default_texture_state()

static void init_default_texture_state ( unsigned int  i,
uint32_t  stage[WINED3D_HIGHEST_TEXTURE_STATE+1] 
)
static

Definition at line 2224 of file stateblock.c.

2225{
2232 stage[WINED3D_TSS_BUMPENV_MAT00] = 0;
2233 stage[WINED3D_TSS_BUMPENV_MAT01] = 0;
2234 stage[WINED3D_TSS_BUMPENV_MAT10] = 0;
2235 stage[WINED3D_TSS_BUMPENV_MAT11] = 0;
2237 stage[WINED3D_TSS_BUMPENV_LSCALE] = 0;
2238 stage[WINED3D_TSS_BUMPENV_LOFFSET] = 0;
2243}
@ WINED3D_TSS_COLOR_ARG2
Definition: wined3d.h:596
@ WINED3D_TSS_BUMPENV_LOFFSET
Definition: wined3d.h:606
@ WINED3D_TSS_ALPHA_OP
Definition: wined3d.h:597
@ WINED3D_TSS_BUMPENV_MAT11
Definition: wined3d.h:603
@ WINED3D_TSS_COLOR_OP
Definition: wined3d.h:594
@ WINED3D_TSS_BUMPENV_MAT10
Definition: wined3d.h:602
@ WINED3D_TSS_TEXCOORD_INDEX
Definition: wined3d.h:604
@ WINED3D_TSS_ALPHA_ARG2
Definition: wined3d.h:599
@ WINED3D_TSS_BUMPENV_MAT01
Definition: wined3d.h:601
@ WINED3D_TSS_ALPHA_ARG0
Definition: wined3d.h:609
@ WINED3D_TSS_BUMPENV_LSCALE
Definition: wined3d.h:605
@ WINED3D_TSS_COLOR_ARG0
Definition: wined3d.h:608
@ WINED3D_TSS_COLOR_ARG1
Definition: wined3d.h:595
@ WINED3D_TSS_ALPHA_ARG1
Definition: wined3d.h:598
@ WINED3D_TSS_RESULT_ARG
Definition: wined3d.h:610
@ WINED3D_TSS_BUMPENV_MAT00
Definition: wined3d.h:600
@ WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
Definition: wined3d.h:607
#define WINED3DTA_CURRENT
Definition: wined3d.h:882
@ WINED3D_TOP_SELECT_ARG1
Definition: wined3d.h:629
@ WINED3D_TOP_DISABLE
Definition: wined3d.h:628
@ WINED3D_TOP_MODULATE
Definition: wined3d.h:631
@ WINED3D_TTFF_DISABLE
Definition: wined3d.h:618
#define WINED3DTA_TEXTURE
Definition: wined3d.h:883

Referenced by state_init_default(), and stateblock_state_init_default().

◆ lights_compare()

static int lights_compare ( const void *  key,
const struct rb_entry *  entry 
)
static

Definition at line 2316 of file stateblock.c.

2317{
2319 unsigned int original_index = (ULONG_PTR)key;
2320
2321 return wined3d_uint32_compare(light->OriginalIndex, original_index);
2322}
#define ULONG_PTR
Definition: config.h:101
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
#define RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:26
Definition: copy.c:22
static int wined3d_uint32_compare(uint32_t x, uint32_t y)

Referenced by state_init(), and wined3d_stateblock_state_init().

◆ resolve_depth_buffer()

static void resolve_depth_buffer ( struct wined3d_device *  device)
static

Definition at line 2714 of file stateblock.c.

2715{
2716 const struct wined3d_state *state = device->cs->c.state;
2717 struct wined3d_rendertarget_view *src_view;
2718 struct wined3d_resource *dst_resource;
2719 struct wined3d_texture *dst_texture;
2720
2721 if (!(dst_texture = wined3d_state_get_ffp_texture(state, 0)))
2722 return;
2723 dst_resource = &dst_texture->resource;
2724 if (!dst_resource->format->depth_size)
2725 return;
2726 if (!(src_view = state->fb.depth_stencil))
2727 return;
2728
2729 wined3d_device_context_resolve_sub_resource(&device->cs->c, dst_resource, 0,
2730 src_view->resource, src_view->sub_resource_idx, dst_resource->format->id);
2731}
void CDECL wined3d_device_context_resolve_sub_resource(struct wined3d_device_context *context, struct wined3d_resource *dst_resource, unsigned int dst_sub_resource_idx, struct wined3d_resource *src_resource, unsigned int src_sub_resource_idx, enum wined3d_format_id format_id)
Definition: device.c:4417
struct wined3d_resource * resource
const struct wined3d_format * format
struct wined3d_resource resource
static struct wined3d_texture * wined3d_state_get_ffp_texture(const struct wined3d_state *state, unsigned int idx)

Referenced by wined3d_device_set_render_state().

◆ sampler_desc_from_sampler_states()

static void sampler_desc_from_sampler_states ( struct wined3d_sampler_desc *  desc,
const uint32_t *  sampler_states,
const struct wined3d_texture *  texture 
)
static

Definition at line 2850 of file stateblock.c.

2852{
2853 const struct wined3d_d3d_info *d3d_info = &texture->resource.device->adapter->d3d_info;
2854
2855 desc->address_u = get_texture_address_mode(texture, sampler_states[WINED3D_SAMP_ADDRESS_U]);
2856 desc->address_v = get_texture_address_mode(texture, sampler_states[WINED3D_SAMP_ADDRESS_V]);
2857 desc->address_w = get_texture_address_mode(texture, sampler_states[WINED3D_SAMP_ADDRESS_W]);
2858 wined3d_color_from_d3dcolor((struct wined3d_color *)desc->border_color,
2859 sampler_states[WINED3D_SAMP_BORDER_COLOR]);
2861 FIXME("Unrecognized or unsupported WINED3D_SAMP_MAG_FILTER %#x.\n",
2862 sampler_states[WINED3D_SAMP_MAG_FILTER]);
2865 FIXME("Unrecognized or unsupported WINED3D_SAMP_MIN_FILTER %#x.\n",
2866 sampler_states[WINED3D_SAMP_MIN_FILTER]);
2869 FIXME("Unrecognized or unsupported WINED3D_SAMP_MIP_FILTER %#x.\n",
2870 sampler_states[WINED3D_SAMP_MIP_FILTER]);
2871 desc->mip_filter = min(max(sampler_states[WINED3D_SAMP_MIP_FILTER], WINED3D_TEXF_NONE), WINED3D_TEXF_LINEAR);
2872 desc->lod_bias = int_to_float(sampler_states[WINED3D_SAMP_MIPMAP_LOD_BIAS]);
2873 desc->min_lod = -1000.0f;
2874 desc->max_lod = 1000.0f;
2875
2876 /* The LOD is already clamped to texture->level_count in wined3d_stateblock_set_texture_lod(). */
2877 if (texture->flags & WINED3D_TEXTURE_COND_NP2)
2878 desc->mip_base_level = 0;
2879 else if (desc->mip_filter == WINED3D_TEXF_NONE)
2880 desc->mip_base_level = texture->lod;
2881 else
2882 desc->mip_base_level = min(max(sampler_states[WINED3D_SAMP_MAX_MIP_LEVEL], texture->lod), texture->level_count - 1);
2883
2884 desc->max_anisotropy = sampler_states[WINED3D_SAMP_MAX_ANISOTROPY];
2888 || (texture->flags & WINED3D_TEXTURE_COND_NP2))
2889 desc->max_anisotropy = 1;
2890 desc->compare = texture->resource.format_caps & WINED3D_FORMAT_CAP_SHADOW;
2891 desc->comparison_func = WINED3D_CMP_LESSEQUAL;
2892
2893 /* Only use the LSB of the WINED3D_SAMP_SRGB_TEXTURE value. This matches
2894 * the behaviour of the AMD Windows driver.
2895 *
2896 * Might & Magic: Heroes VI - Shades of Darkness sets
2897 * WINED3D_SAMP_SRGB_TEXTURE to a large value that looks like a
2898 * pointer—presumably by accident—and expects sRGB decoding to be
2899 * disabled. */
2900 desc->srgb_decode = sampler_states[WINED3D_SAMP_SRGB_TEXTURE] & 0x1;
2901
2902 if (!(texture->resource.format_caps & WINED3D_FORMAT_CAP_FILTERING))
2903 {
2904 desc->mag_filter = WINED3D_TEXF_POINT;
2905 desc->min_filter = WINED3D_TEXF_POINT;
2906 desc->mip_filter = WINED3D_TEXF_NONE;
2907 }
2908
2909 if (texture->flags & WINED3D_TEXTURE_COND_NP2)
2910 {
2911 desc->mip_filter = WINED3D_TEXF_NONE;
2912 if (!d3d_info->unconditional_npot)
2913 desc->min_filter = WINED3D_TEXF_POINT;
2914 }
2915}
static void wined3d_color_from_d3dcolor(struct wined3d_color *wined3d_colour, D3DCOLOR d3d_colour)
Definition: device.c:34
#define min(a, b)
Definition: monoChain.cc:55
uint32_t unconditional_npot
#define max(a, b)
Definition: svc.c:63
static enum wined3d_texture_address get_texture_address_mode(const struct wined3d_texture *texture, enum wined3d_texture_address t)
Definition: stateblock.c:2833
@ WINED3D_TEXF_ANISOTROPIC
Definition: wined3d.h:708
@ WINED3D_TEXF_LINEAR
Definition: wined3d.h:707
#define WINED3D_FORMAT_CAP_SHADOW
#define WINED3D_FORMAT_CAP_FILTERING
static float int_to_float(uint32_t i)

Referenced by wined3d_device_apply_stateblock().

◆ set_light_changed()

static void set_light_changed ( struct wined3d_stateblock *  stateblock,
struct wined3d_light_info *  light_info 
)
static

Definition at line 697 of file stateblock.c.

698{
699 if (!light_info->changed)
700 {
701 list_add_tail(&stateblock->changed.changed_lights, &light_info->changed_entry);
702 light_info->changed = true;
703 }
704 stateblock->changed.lights = 1;
705}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
struct list changed_entry
struct wined3d_saved_states changed
Definition: stateblock.c:84

Referenced by wined3d_stateblock_set_light(), and wined3d_stateblock_set_light_enable().

◆ state_cleanup()

void state_cleanup ( struct wined3d_state *  state)

Definition at line 648 of file stateblock.c.

649{
651 unsigned int i;
652
653 if (!(state->flags & WINED3D_STATE_NO_REF))
655
656 for (i = 0; i < WINED3D_MAX_ACTIVE_LIGHTS; ++i)
657 {
658 state->light_state.lights[i] = NULL;
659 }
660
661 RB_FOR_EACH_ENTRY_DESTRUCTOR(light, cursor, &state->light_state.lights_tree, struct wined3d_light_info, entry)
662 {
663 if (light->changed)
664 list_remove(&light->changed_entry);
665 rb_remove(&state->light_state.lights_tree, &light->entry);
666 free(light);
667 }
668}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
const char cursor[]
Definition: icontest.c:13
#define RB_FOR_EACH_ENTRY_DESTRUCTOR(elem, elem2, tree, type, field)
Definition: rbtree.h:160
static void rb_remove(struct rb_tree *tree, struct rb_entry *entry)
Definition: rbtree.h:272
void state_unbind_resources(struct wined3d_state *state)
Definition: stateblock.c:475
#define WINED3D_STATE_NO_REF
#define WINED3D_MAX_ACTIVE_LIGHTS

Referenced by wined3d_cs_create(), wined3d_cs_destroy(), wined3d_cs_exec_reset_state(), wined3d_device_context_reset_state(), wined3d_device_reset(), wined3d_device_uninit_3d(), and wined3d_state_destroy().

◆ state_init()

void state_init ( struct wined3d_state *  state,
const struct wined3d_d3d_info *  d3d_info,
uint32_t  flags,
enum wined3d_feature_level  feature_level 
)

Definition at line 2324 of file stateblock.c.

2326{
2327 state->feature_level = feature_level;
2328 state->flags = flags;
2329
2330 rb_init(&state->light_state.lights_tree, lights_compare);
2331
2333 state_init_default(state, d3d_info);
2334}
GLbitfield flags
Definition: glext.h:7161
static void rb_init(struct rb_tree *tree, rb_compare_func_t compare)
Definition: rbtree.h:173
static void state_init_default(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info)
Definition: stateblock.c:2270
static int lights_compare(const void *key, const struct rb_entry *entry)
Definition: stateblock.c:2316
#define WINED3D_STATE_INIT_DEFAULT

Referenced by wined3d_state_create(), and wined3d_state_reset().

◆ state_init_default()

static void state_init_default ( struct wined3d_state *  state,
const struct wined3d_d3d_info *  d3d_info 
)
static

Definition at line 2270 of file stateblock.c.

2271{
2272 struct wined3d_matrix identity;
2273 unsigned int i, j;
2274
2275 TRACE("state %p, d3d_info %p.\n", state, d3d_info);
2276
2278 state->primitive_type = WINED3D_PT_UNDEFINED;
2279 state->patch_vertex_count = 0;
2280
2281 /* Set some of the defaults for lights, transforms etc */
2282 state->transforms[WINED3D_TS_PROJECTION] = identity;
2283 state->transforms[WINED3D_TS_VIEW] = identity;
2284 for (i = 0; i < 256; ++i)
2285 {
2286 state->transforms[WINED3D_TS_WORLD_MATRIX(i)] = identity;
2287 }
2288
2289 init_default_render_states(state->render_states, d3d_info);
2290
2291 /* Texture Stage States - Put directly into state block, we will call function below */
2292 for (i = 0; i < WINED3D_MAX_FFP_TEXTURES; ++i)
2293 {
2294 TRACE("Setting up default texture states for texture Stage %u.\n", i);
2295 state->transforms[WINED3D_TS_TEXTURE0 + i] = identity;
2296 init_default_texture_state(i, state->texture_states[i]);
2297 }
2298
2299 state->blend_factor.r = 1.0f;
2300 state->blend_factor.g = 1.0f;
2301 state->blend_factor.b = 1.0f;
2302 state->blend_factor.a = 1.0f;
2303
2304 state->sample_mask = 0xffffffff;
2305
2306 for (i = 0; i < WINED3D_MAX_STREAMS; ++i)
2307 state->streams[i].frequency = 1;
2308
2309 for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
2310 {
2311 for (j = 0; j < MAX_CONSTANT_BUFFERS; ++j)
2312 state->cb[i][j].size = WINED3D_MAX_CONSTANT_BUFFER_SIZE * 16;
2313 }
2314}
void get_identity_matrix(struct wined3d_matrix *mat)
Definition: utils.c:5575
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
for(i=0;i< sizeof(testsuite)/sizeof(testsuite[0]);++i) ok(call_test(testsuite[i].func)
static void init_default_render_states(unsigned int rs[WINEHIGHEST_RENDER_STATE+1], const struct wined3d_d3d_info *d3d_info)
Definition: stateblock.c:2084
static void init_default_texture_state(unsigned int i, uint32_t stage[WINED3D_HIGHEST_TEXTURE_STATE+1])
Definition: stateblock.c:2224
#define WINED3D_TS_WORLD_MATRIX(index)
Definition: wined3d.h:683
@ WINED3D_PT_UNDEFINED
Definition: wined3d.h:75
#define WINED3D_MAX_CONSTANT_BUFFER_SIZE
Definition: wined3d.h:1607
#define WINED3D_MAX_STREAMS
Definition: wined3d.h:1596
@ WINED3D_SHADER_TYPE_COUNT
Definition: wined3d.h:849
@ WINED3D_TS_TEXTURE0
Definition: wined3d.h:669
@ WINED3D_TS_PROJECTION
Definition: wined3d.h:668
@ WINED3D_TS_VIEW
Definition: wined3d.h:667
#define WINED3D_MAX_FFP_TEXTURES
Definition: wined3d.h:1597
#define MAX_CONSTANT_BUFFERS

Referenced by state_init().

◆ state_unbind_resources()

void state_unbind_resources ( struct wined3d_state *  state)

Definition at line 475 of file stateblock.c.

476{
479 struct wined3d_vertex_declaration *decl;
480 struct wined3d_blend_state *blend_state;
481 struct wined3d_rendertarget_view *rtv;
482 struct wined3d_sampler *sampler;
483 struct wined3d_buffer *buffer;
484 struct wined3d_shader *shader;
485 unsigned int i, j;
486
487 if ((decl = state->vertex_declaration))
488 {
489 state->vertex_declaration = NULL;
491 }
492
493 for (i = 0; i < WINED3D_MAX_STREAM_OUTPUT_BUFFERS; ++i)
494 {
495 if ((buffer = state->stream_output[i].buffer))
496 {
497 state->stream_output[i].buffer = NULL;
499 }
500 }
501
502 for (i = 0; i < WINED3D_MAX_STREAMS; ++i)
503 {
504 if ((buffer = state->streams[i].buffer))
505 {
506 state->streams[i].buffer = NULL;
508 }
509 }
510
511 if ((buffer = state->index_buffer))
512 {
513 state->index_buffer = NULL;
515 }
516
517 for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i)
518 {
519 if ((shader = state->shader[i]))
520 {
521 state->shader[i] = NULL;
523 }
524
525 for (j = 0; j < MAX_CONSTANT_BUFFERS; ++j)
526 {
527 if ((buffer = state->cb[i][j].buffer))
528 {
529 state->cb[i][j].buffer = NULL;
531 }
532 }
533
534 for (j = 0; j < MAX_SAMPLER_OBJECTS; ++j)
535 {
536 if ((sampler = state->sampler[i][j]))
537 {
538 state->sampler[i][j] = NULL;
540 }
541 }
542
543 for (j = 0; j < MAX_SHADER_RESOURCE_VIEWS; ++j)
544 {
545 if ((srv = state->shader_resource_view[i][j]))
546 {
547 state->shader_resource_view[i][j] = NULL;
550 }
551 }
552 }
553
554 for (i = 0; i < WINED3D_PIPELINE_COUNT; ++i)
555 {
556 for (j = 0; j < MAX_UNORDERED_ACCESS_VIEWS; ++j)
557 {
558 if ((uav = state->unordered_access_view[i][j]))
559 {
560 state->unordered_access_view[i][j] = NULL;
562 }
563 }
564 }
565
566 if ((blend_state = state->blend_state))
567 {
568 state->blend_state = NULL;
569 wined3d_blend_state_decref(blend_state);
570 }
571
572 for (i = 0; i < ARRAY_SIZE(state->fb.render_targets); ++i)
573 {
574 if ((rtv = state->fb.render_targets[i]))
575 {
576 state->fb.render_targets[i] = NULL;
578 }
579 }
580
581 if ((rtv = state->fb.depth_stencil))
582 {
583 state->fb.depth_stencil = NULL;
585 }
586}
#define ARRAY_SIZE(A)
Definition: main.h:20
ULONG CDECL wined3d_buffer_decref(struct wined3d_buffer *buffer)
Definition: buffer.c:459
ULONG CDECL wined3d_blend_state_decref(struct wined3d_blend_state *state)
Definition: device.c:284
ULONG CDECL wined3d_shader_decref(struct wined3d_shader *shader)
Definition: shader.c:2588
ULONG CDECL wined3d_unordered_access_view_decref(struct wined3d_unordered_access_view *view)
Definition: view.c:1536
ULONG CDECL wined3d_rendertarget_view_decref(struct wined3d_rendertarget_view *view)
Definition: view.c:379
ULONG CDECL wined3d_shader_resource_view_decref(struct wined3d_shader_resource_view *view)
Definition: view.c:990
GLuint buffer
Definition: glext.h:5915
GLuint sampler
Definition: glext.h:7283
GLuint shader
Definition: glext.h:6030
ULONG CDECL wined3d_sampler_decref(struct wined3d_sampler *sampler)
Definition: sampler.c:35
ULONG CDECL wined3d_vertex_declaration_decref(struct wined3d_vertex_declaration *declaration)
#define WINED3D_MAX_STREAM_OUTPUT_BUFFERS
Definition: wined3d.h:1576
@ WINED3D_PIPELINE_COUNT
Definition: wined3d.h:857
#define MAX_SAMPLER_OBJECTS
#define MAX_UNORDERED_ACCESS_VIEWS
static void wined3d_srv_bind_count_dec(struct wined3d_shader_resource_view *srv)
#define MAX_SHADER_RESOURCE_VIEWS

Referenced by state_cleanup(), and wined3d_device_reset().

◆ stateblock_init()

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

Definition at line 2450 of file stateblock.c.

2452{
2453 const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
2454
2455 stateblock->ref = 1;
2456 stateblock->device = device;
2457 stateblock->stateblock_state.light_state = &stateblock->light_state;
2460
2461 stateblock->changed.store_stream_offset = 1;
2462 list_init(&stateblock->changed.changed_lights);
2463
2466
2468 return WINED3D_OK;
2469
2470 TRACE("Updating changed flags appropriate for type %#x.\n", type);
2471
2472 switch (type)
2473 {
2474 case WINED3D_SBT_ALL:
2475 stateblock_init_lights(stateblock, &device_state->stateblock_state.light_state->lights_tree);
2477 d3d_info->limits.vs_uniform_count, d3d_info->limits.ps_uniform_count);
2478 break;
2479
2482 d3d_info->limits.ps_uniform_count);
2483 break;
2484
2486 stateblock_init_lights(stateblock, &device_state->stateblock_state.light_state->lights_tree);
2488 d3d_info->limits.vs_uniform_count);
2489 break;
2490
2491 default:
2492 FIXME("Unrecognized state block type %#x.\n", type);
2493 break;
2494 }
2495
2498
2499 /* According to the tests, stream offset is not updated in the captured state if
2500 * the state was captured on state block creation. This is not the case for
2501 * state blocks initialized with BeginStateBlock / EndStateBlock, multiple
2502 * captures get stream offsets updated. */
2503 stateblock->changed.store_stream_offset = 0;
2504
2505 return WINED3D_OK;
2506}
static void list_init(struct list_entry *head)
Definition: list.h:51
struct wined3d_device * device
Definition: stateblock.c:82
struct wined3d_stateblock_state stateblock_state
Definition: stateblock.c:86
struct wined3d_light_state light_state
Definition: stateblock.c:87
static void wined3d_stateblock_state_init(struct wined3d_stateblock_state *state, const struct wined3d_device *device, uint32_t flags)
Definition: stateblock.c:2422
static void wined3d_stateblock_invalidate_initial_states(struct wined3d_stateblock *stateblock)
Definition: stateblock.c:2435
void CDECL wined3d_stateblock_init_contained_states(struct wined3d_stateblock *stateblock)
Definition: stateblock.c:393
static void stateblock_savedstates_set_all(struct wined3d_saved_states *states, DWORD vs_consts, DWORD ps_consts)
Definition: stateblock.c:281
void CDECL wined3d_stateblock_capture(struct wined3d_stateblock *stateblock, const struct wined3d_stateblock *device_state)
Definition: stateblock.c:893
static void stateblock_savedstates_set_pixel(struct wined3d_saved_states *states, const DWORD num_constants)
Definition: stateblock.c:338
static void stateblock_savedstates_set_vertex(struct wined3d_saved_states *states, const DWORD num_constants)
Definition: stateblock.c:364
static void stateblock_init_lights(struct wined3d_stateblock *stateblock, const struct rb_tree *src_tree)
Definition: stateblock.c:450
@ WINED3D_SBT_PIXEL_STATE
Definition: wined3d.h:788
@ WINED3D_SBT_VERTEX_STATE
Definition: wined3d.h:789
@ WINED3D_SBT_PRIMARY
Definition: wined3d.h:791
@ WINED3D_SBT_ALL
Definition: wined3d.h:787
@ WINED3D_SBT_RECORDED
Definition: wined3d.h:790
#define WINED3D_OK
Definition: wined3d.h:33

◆ stateblock_init_lights()

static void stateblock_init_lights ( struct wined3d_stateblock *  stateblock,
const struct rb_tree *  src_tree 
)
static

Definition at line 450 of file stateblock.c.

451{
452 struct rb_tree *dst_tree = &stateblock->stateblock_state.light_state->lights_tree;
453 struct wined3d_light_info *src_light;
454
455 RB_FOR_EACH_ENTRY(src_light, src_tree, struct wined3d_light_info, entry)
456 {
457 struct wined3d_light_info *dst_light = malloc(sizeof(*dst_light));
458
459 *dst_light = *src_light;
460 rb_put(dst_tree, (void *)(ULONG_PTR)dst_light->OriginalIndex, &dst_light->entry);
461 dst_light->changed = true;
462 list_add_tail(&stateblock->changed.changed_lights, &dst_light->changed_entry);
463 }
464}
static int rb_put(struct rb_tree *tree, const void *key, struct rb_entry *entry)
Definition: rbtree.h:204
#define RB_FOR_EACH_ENTRY(elem, tree, type, field)
Definition: rbtree.h:148
Definition: rbtree.h:40
struct rb_entry entry
unsigned int OriginalIndex
uint32_t ULONG_PTR
Definition: typedefs.h:65

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 281 of file stateblock.c.

282{
283 unsigned int i;
284
285 states->indices = 1;
286 states->material = 1;
287 states->viewport = 1;
288 states->vertexDecl = 1;
289 states->pixelShader = 1;
290 states->vertexShader = 1;
291 states->scissorRect = 1;
292 states->alpha_to_coverage = 1;
293 states->lights = 1;
294 states->transforms = 1;
295
296 states->streamSource = 0xffff;
297 states->streamFreq = 0xffff;
298 states->textures = 0xfffff;
301 for (i = 0; i < WINED3D_MAX_FFP_TEXTURES; ++i) states->textureState[i] = 0x3ffff;
302 for (i = 0; i < WINED3D_MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = 0x3ffe;
304 states->pixelShaderConstantsB = 0xffff;
305 states->pixelShaderConstantsI = 0xffff;
306 states->vertexShaderConstantsB = 0xffff;
307 states->vertexShaderConstantsI = 0xffff;
308
309 memset(states->ps_consts_f, 0xffu, sizeof(states->ps_consts_f));
310 memset(states->vs_consts_f, 0xffu, sizeof(states->vs_consts_f));
311}
#define memset(x, y, z)
Definition: compat.h:39
uint32_t textureState[WINED3D_MAX_FFP_TEXTURES]
Definition: stateblock.c:45
uint16_t streamSource
Definition: stateblock.c:42
uint32_t ps_consts_f[WINED3D_BITMAP_SIZE(WINED3D_MAX_PS_CONSTS_F)]
Definition: stateblock.c:38
uint32_t renderState[WINED3D_BITMAP_SIZE(WINEHIGHEST_RENDER_STATE+1)]
Definition: stateblock.c:44
uint32_t scissorRect
Definition: stateblock.c:55
uint16_t vertexShaderConstantsB
Definition: stateblock.c:37
uint16_t pixelShaderConstantsI
Definition: stateblock.c:39
uint32_t transform[WINED3D_BITMAP_SIZE(WINED3D_HIGHEST_TRANSFORM_STATE+1)]
Definition: stateblock.c:41
uint32_t vs_consts_f[WINED3D_BITMAP_SIZE(WINED3D_MAX_VS_CONSTS_F)]
Definition: stateblock.c:35
uint32_t pixelShader
Definition: stateblock.c:53
uint16_t vertexShaderConstantsI
Definition: stateblock.c:36
uint32_t vertexShader
Definition: stateblock.c:54
uint16_t samplerState[WINED3D_MAX_COMBINED_SAMPLERS]
Definition: stateblock.c:46
uint32_t alpha_to_coverage
Definition: stateblock.c:57
uint16_t pixelShaderConstantsB
Definition: stateblock.c:40
static void stateblock_set_all_bits(uint32_t *map, UINT map_size)
Definition: stateblock.c:273
#define WINED3D_MAX_CLIP_DISTANCES
Definition: wined3d.h:1601
#define WINED3D_HIGHEST_TRANSFORM_STATE
Definition: wined3d.h:684
#define WINEHIGHEST_RENDER_STATE
Definition: wined3d.h:415
static uint32_t wined3d_mask_from_size(unsigned int size)

Referenced by stateblock_init(), and wined3d_stateblock_primary_dirtify_all_states().

◆ stateblock_savedstates_set_pixel()

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

Definition at line 338 of file stateblock.c.

339{
340 DWORD texture_mask = 0;
341 WORD sampler_mask = 0;
342 unsigned int i;
343
344 states->pixelShader = 1;
345
346 for (i = 0; i < ARRAY_SIZE(pixel_states_render); ++i)
347 {
349 states->renderState[rs >> 5] |= 1u << (rs & 0x1f);
350 }
351
352 for (i = 0; i < ARRAY_SIZE(pixel_states_texture); ++i)
353 texture_mask |= 1u << pixel_states_texture[i];
354 for (i = 0; i < WINED3D_MAX_FFP_TEXTURES; ++i) states->textureState[i] = texture_mask;
356 sampler_mask |= 1u << pixel_states_sampler[i];
357 for (i = 0; i < WINED3D_MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = sampler_mask;
358 states->pixelShaderConstantsB = 0xffff;
359 states->pixelShaderConstantsI = 0xffff;
360
361 memset(states->ps_consts_f, 0xffu, sizeof(states->ps_consts_f));
362}
unsigned short WORD
Definition: ntddk_ex.h:93
static const DWORD pixel_states_texture[]
Definition: stateblock.c:163
static const DWORD pixel_states_sampler[]
Definition: stateblock.c:184
static const DWORD pixel_states_render[]
Definition: stateblock.c:99

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 364 of file stateblock.c.

365{
366 DWORD texture_mask = 0;
367 WORD sampler_mask = 0;
368 unsigned int i;
369
370 states->vertexDecl = 1;
371 states->vertexShader = 1;
372 states->alpha_to_coverage = 1;
373 states->lights = 1;
374
375 for (i = 0; i < ARRAY_SIZE(vertex_states_render); ++i)
376 {
378 states->renderState[rs >> 5] |= 1u << (rs & 0x1f);
379 }
380
381 for (i = 0; i < ARRAY_SIZE(vertex_states_texture); ++i)
382 texture_mask |= 1u << vertex_states_texture[i];
383 for (i = 0; i < WINED3D_MAX_FFP_TEXTURES; ++i) states->textureState[i] = texture_mask;
385 sampler_mask |= 1u << vertex_states_sampler[i];
386 for (i = 0; i < WINED3D_MAX_COMBINED_SAMPLERS; ++i) states->samplerState[i] = sampler_mask;
387 states->vertexShaderConstantsB = 0xffff;
388 states->vertexShaderConstantsI = 0xffff;
389
390 memset(states->vs_consts_f, 0xffu, sizeof(states->vs_consts_f));
391}
static const DWORD vertex_states_render[]
Definition: stateblock.c:200
static const DWORD vertex_states_sampler[]
Definition: stateblock.c:255
static const DWORD vertex_states_texture[]
Definition: stateblock.c:249

Referenced by stateblock_init().

◆ stateblock_set_all_bits()

static void stateblock_set_all_bits ( uint32_t *  map,
UINT  map_size 
)
inlinestatic

Definition at line 273 of file stateblock.c.

274{
275 DWORD mask = (1u << (map_size & 0x1f)) - 1;
276 memset(map, 0xff, (map_size >> 5) * sizeof(*map));
277 if (mask) map[map_size >> 5] = mask;
278}
Definition: _map.h:48
GLenum GLint GLuint mask
Definition: glext.h:6028

Referenced by stateblock_savedstates_set_all().

◆ stateblock_state_init_default()

static void stateblock_state_init_default ( struct wined3d_stateblock_state *  state,
const struct wined3d_d3d_info *  d3d_info 
)
static

Definition at line 2393 of file stateblock.c.

2395{
2396 struct wined3d_matrix identity;
2397 unsigned int i;
2398
2400
2401 state->transforms[WINED3D_TS_PROJECTION] = identity;
2402 state->transforms[WINED3D_TS_VIEW] = identity;
2403 for (i = 0; i < 256; ++i)
2404 {
2405 state->transforms[WINED3D_TS_WORLD_MATRIX(i)] = identity;
2406 }
2407
2408 init_default_render_states(state->rs, d3d_info);
2409
2410 for (i = 0; i < WINED3D_MAX_FFP_TEXTURES; ++i)
2411 {
2412 state->transforms[WINED3D_TS_TEXTURE0 + i] = identity;
2413 init_default_texture_state(i, state->texture_states[i]);
2414 }
2415
2416 init_default_sampler_states(state->sampler_states);
2417
2418 for (i = 0; i < WINED3D_MAX_STREAMS; ++i)
2419 state->streams[i].frequency = 1;
2420}
static void init_default_sampler_states(uint32_t states[WINED3D_MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE+1])
Definition: stateblock.c:2245

Referenced by wined3d_stateblock_state_init().

◆ texture_binding_might_invalidate_fs_settings()

static bool texture_binding_might_invalidate_fs_settings ( const struct wined3d_stateblock *  stateblock,
const struct wined3d_texture *  texture,
const struct wined3d_texture *  prev,
unsigned int  stage 
)
static

Definition at line 1780 of file stateblock.c.

1782{
1783 const struct wined3d_d3d_info *d3d_info = &stateblock->device->adapter->d3d_info;
1784 const struct wined3d_format *old_format, *new_format;
1785 unsigned int old_usage, new_usage;
1786
1787 /* The source arguments for color and alpha ops have different meanings when
1788 * a NULL texture is bound. */
1789 if (!texture)
1790 return !!prev;
1791 if (!prev)
1792 return true;
1793
1794 old_usage = prev->resource.usage;
1795 new_usage = texture->resource.usage;
1796 if (texture->resource.type != prev->resource.type
1797 || ((old_usage & WINED3DUSAGE_LEGACY_CUBEMAP) != (new_usage & WINED3DUSAGE_LEGACY_CUBEMAP)))
1798 return true;
1799
1800 if (!stage && stateblock->stateblock_state.rs[WINED3D_RS_COLORKEYENABLE]
1801 && (texture->color_key_flags & WINED3D_CKEY_SRC_BLT))
1802 return true;
1803
1804 old_format = prev->resource.format;
1805 new_format = texture->resource.format;
1806
1807 if (is_same_fixup(old_format->color_fixup, new_format->color_fixup))
1808 return false;
1809
1810 if (can_use_texture_swizzle(d3d_info, new_format) && can_use_texture_swizzle(d3d_info, old_format))
1811 return false;
1812
1813 return true;
1814}
struct color_fixup_desc color_fixup
@ WINED3D_RS_COLORKEYENABLE
Definition: wined3d.h:323
#define WINED3D_CKEY_SRC_BLT
Definition: wined3d.h:1341
static BOOL is_same_fixup(struct color_fixup_desc f1, struct color_fixup_desc f2)
static BOOL can_use_texture_swizzle(const struct wined3d_d3d_info *d3d_info, const struct wined3d_format *format)

Referenced by wined3d_stateblock_set_texture().

◆ transpose_matrix()

static void transpose_matrix ( struct wined3d_matrix *  out,
const struct wined3d_matrix *  m 
)
static

Definition at line 260 of file stateblock.c.

261{
262 struct wined3d_matrix temp;
263
264 for (unsigned int i = 0; i < 4; ++i)
265 {
266 for (unsigned int j = 0; j < 4; ++j)
267 (&temp._11)[4 * j + i] = (&m->_11)[4 * i + j];
268 }
269
270 *out = temp;
271}
const GLfloat * m
Definition: glext.h:10848
static calc_node_t temp
Definition: rpn_ieee.c:38
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

Referenced by wined3d_device_apply_stateblock().

◆ WINE_DECLARE_DEBUG_CHANNEL()

WINE_DECLARE_DEBUG_CHANNEL ( winediag  )

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d  )

◆ wined3d_bitmap_set_bits()

static void wined3d_bitmap_set_bits ( uint32_t *  bitmap,
unsigned int  start,
unsigned int  count 
)
static

Definition at line 1332 of file stateblock.c.

1333{
1334 const unsigned int word_bit_count = sizeof(*bitmap) * CHAR_BIT;
1335 const unsigned int shift = start % word_bit_count;
1336 uint32_t mask, last_mask;
1337 unsigned int mask_size;
1338
1339 bitmap += start / word_bit_count;
1340 mask = ~0u << shift;
1341 mask_size = word_bit_count - shift;
1342 last_mask = (1u << (start + count) % word_bit_count) - 1;
1343 if (mask_size <= count)
1344 {
1345 *bitmap |= mask;
1346 ++bitmap;
1347 count -= mask_size;
1348 mask = ~0u;
1349 }
1350 if (count >= word_bit_count)
1351 {
1352 memset(bitmap, 0xffu, count / word_bit_count * sizeof(*bitmap));
1353 bitmap += count / word_bit_count;
1354 count = count % word_bit_count;
1355 }
1356 if (count)
1357 *bitmap |= mask & last_mask;
1358}
UINT32 uint32_t
Definition: types.h:75
#define CHAR_BIT
Definition: cabinet.h:45
GLuint start
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
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 shift
Definition: input.c:3280
Definition: uimain.c:89

Referenced by wined3d_stateblock_set_ps_consts_f(), and wined3d_stateblock_set_vs_consts_f().

◆ wined3d_device_apply_stateblock()

void CDECL wined3d_device_apply_stateblock ( struct wined3d_device *  device,
struct wined3d_stateblock *  stateblock 
)

Definition at line 3038 of file stateblock.c.

3040{
3041 bool set_blend_state = false, set_depth_stencil_state = false;
3042
3043 const struct wined3d_stateblock_state *state = &stateblock->stateblock_state;
3044 const unsigned int word_bit_count = sizeof(DWORD) * CHAR_BIT;
3045 struct wined3d_saved_states *changed = &stateblock->changed;
3046 struct wined3d_device_context *context = &device->cs->c;
3047 unsigned int i, j, start, idx;
3048 bool set_depth_bounds = false;
3049 struct wined3d_range range;
3050 uint32_t map;
3051
3052 TRACE("device %p, stateblock %p.\n", device, stateblock);
3053
3055
3056 if (changed->vertexShader)
3057 {
3058 /* Clip planes are affected by the view matrix, but only if not using
3059 * vertex shaders. */
3061 }
3062
3063 for (start = 0; ; start = range.offset + range.size)
3064 {
3066 break;
3067
3068 wined3d_device_set_vs_consts_f(device, range.offset, range.size, &state->vs_consts_f[range.offset]);
3069 }
3070
3071 map = changed->vertexShaderConstantsI;
3072 for (start = 0; ; start = range.offset + range.size)
3073 {
3075 break;
3076
3077 wined3d_device_set_vs_consts_i(device, range.offset, range.size, &state->vs_consts_i[range.offset]);
3078 }
3079
3080 map = changed->vertexShaderConstantsB;
3081 for (start = 0; ; start = range.offset + range.size)
3082 {
3084 break;
3085
3086 wined3d_device_set_vs_consts_b(device, range.offset, range.size, &state->vs_consts_b[range.offset]);
3087 }
3088
3089 for (start = 0; ; start = range.offset + range.size)
3090 {
3092 break;
3093
3094 wined3d_device_set_ps_consts_f(device, range.offset, range.size, &state->ps_consts_f[range.offset]);
3095 }
3096
3097 map = changed->pixelShaderConstantsI;
3098 for (start = 0; ; start = range.offset + range.size)
3099 {
3101 break;
3102
3103 wined3d_device_set_ps_consts_i(device, range.offset, range.size, &state->ps_consts_i[range.offset]);
3104 }
3105
3106 map = changed->pixelShaderConstantsB;
3107 for (start = 0; ; start = range.offset + range.size)
3108 {
3110 break;
3111
3112 wined3d_device_set_ps_consts_b(device, range.offset, range.size, &state->ps_consts_b[range.offset]);
3113 }
3114
3115 for (i = 0; i < ARRAY_SIZE(changed->renderState); ++i)
3116 {
3117 map = changed->renderState[i];
3118 while (map)
3119 {
3121 idx = i * word_bit_count + j;
3122
3123 switch (idx)
3124 {
3130 case WINED3D_RS_BLENDOP:
3139 set_blend_state = true;
3140 break;
3141
3155 case WINED3D_RS_ZENABLE:
3156 case WINED3D_RS_ZFUNC:
3158 set_depth_stencil_state = true;
3159 break;
3160
3164 set_depth_bounds = true;
3165 break;
3166
3167 case WINED3D_RS_AMBIENT:
3168 changed->lights = 1;
3169 break;
3170
3184 break;
3185
3187 if (state->rs[WINED3D_RS_ANTIALIAS])
3188 FIXME("Antialias not supported yet.\n");
3189 break;
3190
3192 break;
3193
3194 case WINED3D_RS_WRAPU:
3195 if (state->rs[WINED3D_RS_WRAPU])
3196 FIXME("Render state WINED3D_RS_WRAPU not implemented yet.\n");
3197 break;
3198
3199 case WINED3D_RS_WRAPV:
3200 if (state->rs[WINED3D_RS_WRAPV])
3201 FIXME("Render state WINED3D_RS_WRAPV not implemented yet.\n");
3202 break;
3203
3206 FIXME("Render state WINED3D_RS_MONOENABLE not implemented yet.\n");
3207 break;
3208
3209 case WINED3D_RS_ROP2:
3210 if (state->rs[WINED3D_RS_ROP2])
3211 FIXME("Render state WINED3D_RS_ROP2 not implemented yet.\n");
3212 break;
3213
3215 if (state->rs[WINED3D_RS_PLANEMASK])
3216 FIXME("Render state WINED3D_RS_PLANEMASK not implemented yet.\n");
3217 break;
3218
3220 if (!state->rs[WINED3D_RS_LASTPIXEL])
3221 {
3222 static bool warned;
3223 if (!warned)
3224 {
3225 FIXME("Last Pixel Drawing Disabled, not handled yet.\n");
3226 warned = true;
3227 }
3228 }
3229 break;
3230
3232 if (state->rs[WINED3D_RS_ZVISIBLE])
3233 FIXME("WINED3D_RS_ZVISIBLE not implemented.\n");
3234 break;
3235
3237 if (state->rs[WINED3D_RS_SUBPIXEL])
3238 FIXME("Render state WINED3D_RS_SUBPIXEL not implemented yet.\n");
3239 break;
3240
3242 if (state->rs[WINED3D_RS_SUBPIXELX])
3243 FIXME("Render state WINED3D_RS_SUBPIXELX not implemented yet.\n");
3244 break;
3245
3248 FIXME("Stippled Alpha not supported yet.\n");
3249 break;
3250
3253 FIXME("Render state WINED3D_RS_STIPPLEENABLE not implemented yet.\n");
3254 break;
3255
3258 FIXME("Render state WINED3D_RS_MIPMAPLODBIAS not implemented yet.\n");
3259 break;
3260
3263 FIXME("Render state WINED3D_RS_ANISOTROPY not implemented yet.\n");
3264 break;
3265
3268 FIXME("Render state WINED3D_RS_FLUSHBATCH not implemented yet.\n");
3269 break;
3270
3273 FIXME("Render state WINED3D_RS_TRANSLUCENTSORTINDEPENDENT not implemented yet.\n");
3274 break;
3275
3276 case WINED3D_RS_WRAP0:
3277 case WINED3D_RS_WRAP1:
3278 case WINED3D_RS_WRAP2:
3279 case WINED3D_RS_WRAP3:
3280 case WINED3D_RS_WRAP4:
3281 case WINED3D_RS_WRAP5:
3282 case WINED3D_RS_WRAP6:
3283 case WINED3D_RS_WRAP7:
3284 case WINED3D_RS_WRAP8:
3285 case WINED3D_RS_WRAP9:
3286 case WINED3D_RS_WRAP10:
3287 case WINED3D_RS_WRAP11:
3288 case WINED3D_RS_WRAP12:
3289 case WINED3D_RS_WRAP13:
3290 case WINED3D_RS_WRAP14:
3291 case WINED3D_RS_WRAP15:
3292 {
3293 static unsigned int once;
3294
3295 if ((state->rs[idx]) && !once++)
3296 FIXME("(WINED3D_RS_WRAP0) Texture wrapping not yet supported.\n");
3297 break;
3298 }
3299
3300 case WINED3D_RS_EXTENTS:
3301 if (state->rs[WINED3D_RS_EXTENTS])
3302 FIXME("Render state WINED3D_RS_EXTENTS not implemented yet.\n");
3303 break;
3304
3307 FIXME("Render state WINED3D_RS_COLORKEYBLENDENABLE not implemented yet.\n");
3308 break;
3309
3311 {
3312 static unsigned int once;
3313
3314 if ((state->rs[WINED3D_RS_SOFTWAREVERTEXPROCESSING]) && !once++)
3315 FIXME("Software vertex processing not implemented.\n");
3316 break;
3317 }
3318
3321 FIXME("WINED3D_RS_PATCHEDGESTYLE %#x not yet implemented.\n",
3323 break;
3324
3326 {
3327 union
3328 {
3329 uint32_t d;
3330 float f;
3331 } tmpvalue;
3332 tmpvalue.f = 1.0f;
3333
3334 if (state->rs[WINED3D_RS_PATCHSEGMENTS] != tmpvalue.d)
3335 {
3336 static bool displayed = false;
3337
3338 tmpvalue.d = state->rs[WINED3D_RS_PATCHSEGMENTS];
3339 if(!displayed)
3340 FIXME("(WINED3D_RS_PATCHSEGMENTS,%f) not yet implemented.\n", tmpvalue.f);
3341
3342 displayed = true;
3343 }
3344 break;
3345 }
3346
3348 WARN("token: %#x.\n", state->rs[WINED3D_RS_DEBUGMONITORTOKEN]);
3349 break;
3350
3352 break;
3353
3355 break;
3356
3359 FIXME("WINED3D_RS_POSITIONDEGREE %#x not yet implemented.\n",
3361 break;
3362
3365 FIXME("WINED3D_RS_NORMALDEGREE %#x not yet implemented.\n",
3367 break;
3368
3370 break;
3371
3373 break;
3374
3377 FIXME("WINED3D_RS_ENABLEADAPTIVETESSELLATION %#x not yet implemented.\n",
3379 break;
3380
3381 default:
3383 break;
3384 }
3385 }
3386 }
3387
3388 if (set_blend_state || changed->alpha_to_coverage
3390 {
3391 struct wined3d_blend_state *blend_state;
3393 struct wine_rb_entry *entry;
3394 struct wined3d_color colour;
3395 unsigned int sample_mask;
3396
3397 memset(&desc, 0, sizeof(desc));
3398 desc.alpha_to_coverage = state->alpha_to_coverage;
3399 desc.independent = FALSE;
3401 desc.alpha_to_coverage = TRUE;
3402 desc.rt[0].enable = state->rs[WINED3D_RS_ALPHABLENDENABLE];
3403 desc.rt[0].src = state->rs[WINED3D_RS_SRCBLEND];
3404 desc.rt[0].dst = state->rs[WINED3D_RS_DESTBLEND];
3405 desc.rt[0].op = state->rs[WINED3D_RS_BLENDOP];
3407 {
3408 desc.rt[0].src_alpha = state->rs[WINED3D_RS_SRCBLENDALPHA];
3409 desc.rt[0].dst_alpha = state->rs[WINED3D_RS_DESTBLENDALPHA];
3410 desc.rt[0].op_alpha = state->rs[WINED3D_RS_BLENDOPALPHA];
3411 }
3412 else
3413 {
3414 desc.rt[0].src_alpha = state->rs[WINED3D_RS_SRCBLEND];
3415 desc.rt[0].dst_alpha = state->rs[WINED3D_RS_DESTBLEND];
3416 desc.rt[0].op_alpha = state->rs[WINED3D_RS_BLENDOP];
3417 }
3418 desc.rt[0].writemask = state->rs[WINED3D_RS_COLORWRITEENABLE];
3419 desc.rt[1].writemask = state->rs[WINED3D_RS_COLORWRITEENABLE1];
3420 desc.rt[2].writemask = state->rs[WINED3D_RS_COLORWRITEENABLE2];
3421 desc.rt[3].writemask = state->rs[WINED3D_RS_COLORWRITEENABLE3];
3422 if (desc.rt[1].writemask != desc.rt[0].writemask
3423 || desc.rt[2].writemask != desc.rt[0].writemask
3424 || desc.rt[3].writemask != desc.rt[0].writemask)
3425 {
3426 desc.independent = TRUE;
3427 for (i = 1; i < 4; ++i)
3428 {
3429 desc.rt[i].enable = desc.rt[0].enable;
3430 desc.rt[i].src = desc.rt[0].src;
3431 desc.rt[i].dst = desc.rt[0].dst;
3432 desc.rt[i].op = desc.rt[0].op;
3433 desc.rt[i].src_alpha = desc.rt[0].src_alpha;
3434 desc.rt[i].dst_alpha = desc.rt[0].dst_alpha;
3435 desc.rt[i].op_alpha = desc.rt[0].op_alpha;
3436 }
3437 }
3438
3441 else
3442 wined3d_device_context_get_blend_state(context, &colour, &sample_mask);
3443
3444 if ((entry = wine_rb_get(&device->blend_states, &desc)))
3445 {
3446 blend_state = WINE_RB_ENTRY_VALUE(entry, struct wined3d_blend_state, entry);
3447 wined3d_device_context_set_blend_state(context, blend_state, &colour,
3449 }
3451 &wined3d_null_parent_ops, &blend_state)))
3452 {
3453 wined3d_device_context_set_blend_state(context, blend_state, &colour,
3455 if (wine_rb_put(&device->blend_states, &desc, &blend_state->entry) == -1)
3456 {
3457 ERR("Failed to insert blend state.\n");
3458 wined3d_blend_state_decref(blend_state);
3459 }
3460 }
3461 }
3462
3463 if (set_depth_stencil_state)
3464 {
3465 struct wined3d_depth_stencil_state *depth_stencil_state;
3467 struct wine_rb_entry *entry;
3468 unsigned int stencil_ref;
3469
3470 memset(&desc, 0, sizeof(desc));
3471 switch (state->rs[WINED3D_RS_ZENABLE])
3472 {
3473 case WINED3D_ZB_FALSE:
3474 desc.depth = FALSE;
3475 break;
3476
3477 case WINED3D_ZB_USEW:
3478 FIXME("W buffer is not well handled.\n");
3479 case WINED3D_ZB_TRUE:
3480 desc.depth = TRUE;
3481 break;
3482
3483 default:
3484 FIXME("Unrecognized depth buffer type %#x.\n", state->rs[WINED3D_RS_ZENABLE]);
3485 }
3486 desc.depth_write = state->rs[WINED3D_RS_ZWRITEENABLE];
3487 desc.depth_func = state->rs[WINED3D_RS_ZFUNC];
3488 desc.stencil = state->rs[WINED3D_RS_STENCILENABLE];
3489 desc.stencil_read_mask = state->rs[WINED3D_RS_STENCILMASK];
3490 desc.stencil_write_mask = state->rs[WINED3D_RS_STENCILWRITEMASK];
3491 desc.front.fail_op = state->rs[WINED3D_RS_STENCILFAIL];
3492 desc.front.depth_fail_op = state->rs[WINED3D_RS_STENCILZFAIL];
3493 desc.front.pass_op = state->rs[WINED3D_RS_STENCILPASS];
3494 desc.front.func = state->rs[WINED3D_RS_STENCILFUNC];
3495
3497 {
3498 desc.back.fail_op = state->rs[WINED3D_RS_BACK_STENCILFAIL];
3499 desc.back.depth_fail_op = state->rs[WINED3D_RS_BACK_STENCILZFAIL];
3500 desc.back.pass_op = state->rs[WINED3D_RS_BACK_STENCILPASS];
3501 desc.back.func = state->rs[WINED3D_RS_BACK_STENCILFUNC];
3502 }
3503 else
3504 {
3505 desc.back = desc.front;
3506 }
3507
3509 stencil_ref = state->rs[WINED3D_RS_STENCILREF];
3510 else
3512
3513 if ((entry = wine_rb_get(&device->depth_stencil_states, &desc)))
3514 {
3515 depth_stencil_state = WINE_RB_ENTRY_VALUE(entry, struct wined3d_depth_stencil_state, entry);
3516 wined3d_device_context_set_depth_stencil_state(context, depth_stencil_state, stencil_ref);
3517 }
3519 &wined3d_null_parent_ops, &depth_stencil_state)))
3520 {
3521 wined3d_device_context_set_depth_stencil_state(context, depth_stencil_state, stencil_ref);
3522 if (wine_rb_put(&device->depth_stencil_states, &desc, &depth_stencil_state->entry) == -1)
3523 {
3524 ERR("Failed to insert depth/stencil state.\n");
3525 wined3d_depth_stencil_state_decref(depth_stencil_state);
3526 }
3527 }
3528 }
3529
3530 if (set_depth_bounds)
3531 {
3536 }
3537
3538 for (i = 0; i < ARRAY_SIZE(changed->textureState); ++i)
3539 {
3540 map = changed->textureState[i];
3541 while (map)
3542 {
3544
3545 switch (j)
3546 {
3554 break;
3555
3556 default:
3558 }
3559 }
3560 }
3561
3562 for (i = 0; i < ARRAY_SIZE(changed->samplerState); ++i)
3563 {
3566 struct wined3d_texture *texture;
3567 struct wined3d_sampler *sampler;
3568 unsigned int bind_index = i;
3569 struct wine_rb_entry *entry;
3570
3571 if (!changed->samplerState[i] && !(changed->textures & (1u << i)))
3572 continue;
3573
3574 if (!(texture = state->textures[i]))
3575 continue;
3576
3577 memset(&desc, 0, sizeof(desc));
3579
3581 {
3583 bind_index -= WINED3D_VERTEX_SAMPLER_OFFSET;
3584 }
3585
3586 if ((entry = wine_rb_get(&device->samplers, &desc)))
3587 {
3589
3591 }
3593 {
3595
3596 if (wine_rb_put(&device->samplers, &desc, &sampler->entry) == -1)
3597 {
3598 ERR("Failed to insert sampler.\n");
3600 }
3601 }
3602 }
3603
3604 if (state->vertex_declaration && state->vertex_declaration->position_transformed)
3605 {
3606 /* We reuse the projection matrix to undo the translation between
3607 * clip coordinates and pixel coordinates. */
3608 if (changed->position_transformed || changed->viewport)
3609 {
3610 float x = state->viewport.x;
3611 float y = state->viewport.y;
3612 float w = state->viewport.width;
3613 float h = state->viewport.height;
3614 float x_scale = 2.0f / w;
3615 float x_offset = (-(2.0f * x) - w) / w;
3616 float y_scale = 2.0f / -h;
3617 float y_offset = (-(2.0f * y) - h) / -h;
3618 bool depth = (state->rs[WINED3D_RS_ZENABLE] && context->state->fb.depth_stencil);
3619 float z_scale = depth ? 1.0f : 0.0f;
3620 const struct wined3d_matrix matrix =
3621 {
3622 x_scale, 0.0f, 0.0f, 0.0f,
3623 0.0f, y_scale, 0.0f, 0.0f,
3624 0.0f, 0.0f, z_scale, 0.0f,
3625 x_offset, y_offset, 0.0f, 1.0f,
3626 };
3627
3629 offsetof(struct wined3d_ffp_vs_constants, projection_matrix), sizeof(matrix), &matrix);
3630 }
3631
3633 {
3634 /* wined3d_ffp_vs_settings.ortho_fog still needs the
3635 * device state to be set. */
3637 }
3638 }
3639 else if (changed->transforms)
3640 {
3642 {
3643 changed->lights = 1;
3645 }
3646
3648 {
3651 offsetof(struct wined3d_ffp_vs_constants, projection_matrix),
3652 sizeof(state->transforms[WINED3D_TS_PROJECTION]), &state->transforms[WINED3D_TS_PROJECTION]);
3653 /* wined3d_ffp_vs_settings.ortho_fog and vs_compile_args.ortho_fog
3654 * still need the device state to be set. */
3656 }
3657
3658 /* Clip planes are affected by the view matrix. */
3660 }
3661
3662 if (changed->indices)
3663 wined3d_device_context_set_index_buffer(context, state->index_buffer, state->index_format, 0);
3665 if (changed->vertexDecl)
3667
3668 map = changed->streamSource | changed->streamFreq;
3669 while (map)
3670 {
3673 }
3674
3675 map = changed->textures;
3676 while (map)
3677 {
3678 struct wined3d_color float_key[2];
3679 struct wined3d_texture *texture;
3680
3682 texture = state->textures[i];
3684
3685 if (!i && texture && (texture->color_key_flags & WINED3D_CKEY_SRC_BLT))
3686 {
3687 wined3d_format_get_float_color_key(texture->resource.format, &texture->src_blt_color_key, float_key);
3690 offsetof(struct wined3d_ffp_ps_constants, color_key), sizeof(float_key), float_key);
3691 }
3692 }
3693
3694 map = changed->clipplane;
3695 while (map)
3696 {
3698
3699 /* In Direct3D, clipping is done based on the position as transformed
3700 * by the world (model) matrix, but not the view matrix.
3701 *
3702 * GL and Vulkan do not distinguish the world and view, so we pass them
3703 * as a single uniform. That means, however, that we need to unapply the
3704 * view matrix from the clip planes that we are applying. We do this by
3705 * multiplying by the transpose of the inverse of the view matrix.
3706 *
3707 * This works mathematically (c = clip plane, p = position):
3708 *
3709 * clip distance = dot((V⁻¹)ᵀc, VMp)
3710 * = ((V⁻¹)ᵀc)ᵀVMp
3711 * = cᵀV⁻¹VMp
3712 * = cᵀMp
3713 * = dot(c, Mp)
3714 */
3715
3716 if (!state->vs)
3717 {
3718 struct wined3d_matrix matrix;
3719 struct wined3d_vec4 plane;
3720
3721 invert_matrix(&matrix, &state->transforms[WINED3D_TS_VIEW]);
3723 wined3d_vec4_transform(&plane, &state->clip_planes[i], &matrix);
3725 }
3726 else
3727 {
3728 wined3d_device_set_clip_plane(device, i, &state->clip_planes[i]);
3729 }
3730 }
3731
3732 if (changed->material)
3734 offsetof(struct wined3d_ffp_vs_constants, material), sizeof(state->material), &state->material);
3735
3736 if (changed->lights)
3737 {
3738 unsigned int point_idx, spot_idx, directional_idx, parallel_point_idx;
3739 unsigned int point_count = 0, spot_count = 0, directional_count = 0;
3740 struct wined3d_ffp_light_constants constants;
3742
3744 {
3745 wined3d_device_context_set_light(context, light->OriginalIndex, &light->OriginalParms);
3746 wined3d_device_set_light_enable(device, light->OriginalIndex, light->glIndex != -1);
3747 list_remove(&light->changed_entry);
3748 light->changed = false;
3749 }
3750
3752
3753 for (unsigned int i = 0; i < WINED3D_MAX_ACTIVE_LIGHTS; ++i)
3754 {
3755 if (!state->light_state->lights[i])
3756 continue;
3757
3758 switch (state->light_state->lights[i]->OriginalParms.type)
3759 {
3761 ++point_count;
3762 break;
3763 case WINED3D_LIGHT_SPOT:
3764 ++spot_count;
3765 break;
3767 ++directional_count;
3768 break;
3770 break;
3771 default:
3772 FIXME("Unhandled light type %#x.\n", state->light_state->lights[i]->OriginalParms.type);
3773 break;
3774 }
3775 }
3776 point_idx = 0;
3777 spot_idx = point_idx + point_count;
3778 directional_idx = spot_idx + spot_count;
3779 parallel_point_idx = directional_idx + directional_count;
3780
3781 for (unsigned int i = 0; i < WINED3D_MAX_ACTIVE_LIGHTS; ++i)
3782 {
3783 const struct wined3d_light_info *light_info = state->light_state->lights[i];
3784 const struct wined3d_light_constants *light_constants;
3786 unsigned int idx;
3787
3788 if (!light_info)
3789 continue;
3790 type = light_info->OriginalParms.type;
3791 light_constants = &state->light_state->lights[i]->constants;
3792
3793 switch (type)
3794 {
3796 idx = point_idx++;
3797 break;
3798 case WINED3D_LIGHT_SPOT:
3799 idx = spot_idx++;
3800 break;
3802 idx = directional_idx++;
3803 break;
3805 idx = parallel_point_idx++;
3806 break;
3807 default:
3808 FIXME("Unhandled light type %#x.\n", type);
3809 continue;
3810 }
3811 constants.lights[idx] = *light_constants;
3812
3814 wined3d_vec4_transform(&constants.lights[idx].position,
3815 &light_constants->position, &state->transforms[WINED3D_TS_VIEW]);
3817 wined3d_vec4_transform(&constants.lights[idx].direction,
3818 &light_constants->direction, &state->transforms[WINED3D_TS_VIEW]);
3819 }
3820
3823 }
3824
3825 if (changed->modelview_matrices)
3826 {
3827 union wined3d_ffp_vs_modelview_matrices matrices;
3828
3829 get_modelview_matrix(state, 0, &matrices.modelview_matrices[0]);
3830
3832 {
3833 for (i = 1; i < MAX_VERTEX_BLENDS; ++i)
3834 get_modelview_matrix(state, i, &matrices.modelview_matrices[i]);
3835
3838 offsetof(struct wined3d_ffp_vs_constants, modelview), sizeof(matrices), &matrices);
3839 }
3840 else
3841 {
3842 compute_normal_matrix(&matrices.not_blended.normal_matrix,
3843 device->adapter->d3d_info.wined3d_creation_flags & WINED3D_LEGACY_FFP_LIGHTING,
3844 &matrices.not_blended.modelview_matrix);
3845
3848 offsetof(struct wined3d_ffp_vs_constants, modelview), sizeof(matrices.not_blended), &matrices);
3849 }
3850 }
3851
3852 if (changed->texture_matrices)
3853 {
3855
3856 for (i = 0; i < WINED3D_MAX_FFP_TEXTURES; ++i)
3857 get_texture_matrix(state, i, &constants.texture_matrices[i]);
3861 sizeof(constants.texture_matrices), constants.texture_matrices);
3862 }
3863
3864 if (changed->point_scale)
3865 {
3866 struct wined3d_ffp_point_constants constants;
3867
3869
3871 {
3872 float scale_factor = state->viewport.height * state->viewport.height;
3873
3877 }
3878 else
3879 {
3880 constants.scale_const = 1.0f;
3881 constants.scale_linear = 0.0f;
3882 constants.scale_quad = 0.0f;
3883 }
3884
3887 }
3888
3889 if (changed->bumpenv_constants)
3890 {
3891 struct wined3d_ffp_bumpenv_constants constants;
3892
3893 for (unsigned int i = 0; i < WINED3D_MAX_FFP_TEXTURES; ++i)
3894 {
3895 constants.matrices[i]._00 = int_to_float(state->texture_states[i][WINED3D_TSS_BUMPENV_MAT00]);
3896 constants.matrices[i]._01 = int_to_float(state->texture_states[i][WINED3D_TSS_BUMPENV_MAT01]);
3897 constants.matrices[i]._10 = int_to_float(state->texture_states[i][WINED3D_TSS_BUMPENV_MAT10]);
3898 constants.matrices[i]._11 = int_to_float(state->texture_states[i][WINED3D_TSS_BUMPENV_MAT11]);
3899 constants.loffset[i] = int_to_float(state->texture_states[i][WINED3D_TSS_BUMPENV_LOFFSET]);
3900 constants.lscale[i] = int_to_float(state->texture_states[i][WINED3D_TSS_BUMPENV_LSCALE]);
3901 }
3902
3904 offsetof(struct wined3d_ffp_ps_constants, bumpenv), sizeof(constants), &constants);
3905 }
3906
3907 if (changed->ffp_ps_constants)
3908 {
3909 static const struct wined3d_color specular_enabled = {1.0f, 1.0f, 1.0f, 0.0f};
3910 static const struct wined3d_color specular_disabled;
3912
3913 for (i = 0; i < WINED3D_MAX_FFP_TEXTURES; ++i)
3914 wined3d_color_from_d3dcolor(&constants.texture_constants[i], state->texture_states[i][WINED3D_TSS_CONSTANT]);
3915
3917
3918 constants.specular_enable = state->rs[WINED3D_RS_SPECULARENABLE] ? specular_enabled : specular_disabled;
3919
3922 }
3923
3925 {
3926 float f = (state->rs[WINED3D_RS_ALPHAREF] & 0xff) / 255.0f;
3927
3930 offsetof(struct wined3d_ffp_ps_constants, alpha_test_ref), sizeof(f), &f);
3931 }
3932
3933 if (changed->vertexShader)
3934 {
3942 }
3943 if (changed->pixelShader)
3944 {
3952 }
3953
3954 /* XXX: We don't invalidate HLSL shaders for every field contained in
3955 * wined3d_ffp_vs_settings / ffp_frag_settings; only the ones that the HLSL
3956 * FFP pipeline cares about. The rest should eventually be removed from
3957 * those structs and left only in vs_compile_args / ps_compile_args. */
3958
3959 if (changed->ffp_vs_settings
3960 && (!state->vs || !state->vertex_declaration || state->vertex_declaration->position_transformed))
3961 {
3962 if (device->adapter->d3d_info.ffp_hlsl)
3963 {
3964 struct wined3d_shader *shader = get_ffp_vertex_shader(device, device->cs->c.state);
3965
3969 }
3970 else
3971 {
3972 /* Force invalidation of the vertex shader. */
3974 }
3975 }
3976
3977 if (changed->ffp_ps_settings && !state->ps)
3978 {
3979 if (device->adapter->d3d_info.ffp_hlsl)
3980 {
3981 struct wined3d_shader *shader = get_ffp_pixel_shader(device, device->cs->c.state);
3982
3986 }
3987 else
3988 {
3989 /* Force invalidation of the pixel shader. */
3991 }
3992 }
3993
3996
3997 assert(list_empty(&stateblock->changed.changed_lights));
3998 memset(&stateblock->changed, 0, sizeof(stateblock->changed));
3999 list_init(&stateblock->changed.changed_lights);
4000
4001 TRACE("Applied stateblock %p.\n", stateblock);
4002}
static int list_empty(struct list_entry *head)
Definition: list.h:58
#define WARN(fmt,...)
Definition: precomp.h:61
void wined3d_device_context_push_constants(struct wined3d_device_context *context, enum wined3d_push_constants type, uint32_t update_mask, unsigned int start_idx, unsigned int count, const void *constants)
Definition: cs.c:2231
void wined3d_device_context_set_depth_bounds(struct wined3d_device_context *context, bool enable, float min_depth, float max_depth)
Definition: cs.c:1871
void wined3d_device_context_emit_set_shader(struct wined3d_device_context *context, enum wined3d_shader_type type, struct wined3d_shader *shader)
Definition: cs.c:1768
range
Definition: d3dx9_private.h:58
void CDECL wined3d_device_context_set_depth_stencil_state(struct wined3d_device_context *context, struct wined3d_depth_stencil_state *depth_stencil_state, unsigned int stencil_ref)
Definition: device.c:2077
struct wined3d_depth_stencil_state *CDECL wined3d_device_context_get_depth_stencil_state(const struct wined3d_device_context *context, unsigned int *stencil_ref)
Definition: device.c:1871
void CDECL wined3d_device_context_set_shader(struct wined3d_device_context *context, enum wined3d_shader_type type, struct wined3d_shader *shader)
Definition: device.c:1984
ULONG CDECL wined3d_depth_stencil_state_decref(struct wined3d_depth_stencil_state *state)
Definition: device.c:359
void CDECL wined3d_device_context_set_blend_state(struct wined3d_device_context *context, struct wined3d_blend_state *blend_state, const struct wined3d_color *blend_factor, unsigned int sample_mask)
Definition: device.c:2050
void CDECL wined3d_device_context_set_vertex_declaration(struct wined3d_device_context *context, struct wined3d_vertex_declaration *declaration)
Definition: device.c:2588
HRESULT CDECL wined3d_device_context_set_stream_sources(struct wined3d_device_context *context, unsigned int start_idx, unsigned int count, const struct wined3d_stream_state *streams)
Definition: device.c:2510
void CDECL wined3d_device_context_set_samplers(struct wined3d_device_context *context, enum wined3d_shader_type type, unsigned int start_idx, unsigned int count, struct wined3d_sampler *const *samplers)
Definition: device.c:2243
HRESULT CDECL wined3d_blend_state_create(struct wined3d_device *device, const struct wined3d_blend_state_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_blend_state **state)
Definition: device.c:313
HRESULT CDECL wined3d_depth_stencil_state_create(struct wined3d_device *device, const struct wined3d_depth_stencil_state_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_depth_stencil_state **state)
Definition: device.c:404
struct wined3d_blend_state *CDECL wined3d_device_context_get_blend_state(const struct wined3d_device_context *context, struct wined3d_color *blend_factor, unsigned int *sample_mask)
Definition: device.c:1859
void CDECL wined3d_device_context_set_index_buffer(struct wined3d_device_context *context, struct wined3d_buffer *buffer, enum wined3d_format_id format_id, unsigned int offset)
Definition: device.c:2557
void get_modelview_matrix(const struct wined3d_stateblock_state *state, unsigned int index, struct wined3d_matrix *mat)
Definition: utils.c:5588
void compute_normal_matrix(struct wined3d_matrix *normal_matrix, BOOL legacy_lighting, const struct wined3d_matrix *modelview)
Definition: utils.c:7042
BOOL invert_matrix(struct wined3d_matrix *out, const struct wined3d_matrix *m)
Definition: utils.c:6775
unsigned int idx
Definition: utils.c:40
void get_texture_matrix(const struct wined3d_stateblock_state *state, const unsigned int tex, struct wined3d_matrix *mat)
Definition: utils.c:5671
void wined3d_format_get_float_color_key(const struct wined3d_format *format, const struct wined3d_color_key *key, struct wined3d_color *float_colors)
Definition: utils.c:5997
#define assert(_expr)
Definition: assert.h:32
POINTL point
Definition: edittest.c:50
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLfloat f
Definition: glext.h:7540
GLuint GLenum matrix
Definition: glext.h:9407
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
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 GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum GLint const GLfloat GLenum GLint const GLushort GLint GLint GLsizei GLsizei GLenum GLsizei GLsizei GLenum GLenum const GLvoid GLenum plane
Definition: glfuncs.h:270
#define SUCCEEDED(hr)
Definition: intsafe.h:50
int scale_factor
Definition: jpeglib.h:997
constants
Definition: resource.c:30
#define DWORD
Definition: nt_native.h:44
HRESULT CDECL wined3d_sampler_create(struct wined3d_device *device, const struct wined3d_sampler_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler)
Definition: sampler.c:287
#define offsetof(TYPE, MEMBER)
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:242
Definition: http.c:7252
struct wine_rb_entry entry
struct wine_rb_entry entry
struct wined3d_matrix texture_matrices[WINED3D_MAX_FFP_TEXTURES]
struct wined3d_vec4 position direction
struct wined3d_light OriginalParms
uint32_t point_scale
Definition: stateblock.c:66
uint32_t texture_matrices
Definition: stateblock.c:64
uint32_t bumpenv_constants
Definition: stateblock.c:71
uint32_t modelview_matrices
Definition: stateblock.c:65
uint32_t ffp_vs_settings
Definition: stateblock.c:67
uint32_t position_transformed
Definition: stateblock.c:70
uint32_t ffp_ps_constants
Definition: stateblock.c:63
uint32_t ffp_ps_settings
Definition: stateblock.c:68
@ VKD3D_SHADER_D3DBC_BOOL_CONSTANT_REGISTER
Definition: vkd3d_shader.h:919
@ VKD3D_SHADER_D3DBC_FLOAT_CONSTANT_REGISTER
Definition: vkd3d_shader.h:915
@ VKD3D_SHADER_D3DBC_INT_CONSTANT_REGISTER
Definition: vkd3d_shader.h:917
const struct wined3d_parent_ops wined3d_null_parent_ops
Definition: directx.c:3472
static void wined3d_device_set_vs_consts_b(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const BOOL *constants)
Definition: stateblock.c:2552
static void wined3d_device_set_texture(struct wined3d_device *device, unsigned int stage, struct wined3d_texture *texture)
Definition: stateblock.c:2770
static void bind_push_constant_buffer(struct wined3d_device *device, enum wined3d_push_constants type, enum wined3d_shader_type shader_type, unsigned int shader_binding)
Definition: stateblock.c:3024
static struct wined3d_shader * get_ffp_pixel_shader(struct wined3d_device *device, const struct wined3d_state *state)
Definition: stateblock.c:2999
static void wined3d_device_set_clip_plane(struct wined3d_device *device, unsigned int plane_idx, const struct wined3d_vec4 *plane)
Definition: stateblock.c:2696
static void wined3d_device_context_set_light(struct wined3d_device_context *context, unsigned int light_idx, const struct wined3d_light *light)
Definition: stateblock.c:2661
static void wined3d_device_set_render_state(struct wined3d_device *device, enum wined3d_render_state state, unsigned int value)
Definition: stateblock.c:2733
static void wined3d_device_set_base_vertex_index(struct wined3d_device *device, int base_index)
Definition: stateblock.c:2545
static void wined3d_device_set_ps_consts_b(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const BOOL *constants)
Definition: stateblock.c:2603
static void wined3d_device_set_ps_consts_f(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants)
Definition: stateblock.c:2637
static void wined3d_device_set_ps_consts_i(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants)
Definition: stateblock.c:2620
static void sampler_desc_from_sampler_states(struct wined3d_sampler_desc *desc, const uint32_t *sampler_states, const struct wined3d_texture *texture)
Definition: stateblock.c:2850
static void wined3d_device_set_transform(struct wined3d_device *device, enum wined3d_transform_state state, const struct wined3d_matrix *matrix)
Definition: stateblock.c:2808
static void wined3d_device_set_vs_consts_f(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants)
Definition: stateblock.c:2586
static void wined3d_device_set_vs_consts_i(struct wined3d_device *device, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants)
Definition: stateblock.c:2569
static void wined3d_device_set_texture_stage_state(struct wined3d_device *device, unsigned int stage, enum wined3d_texture_stage_state state, uint32_t value)
Definition: stateblock.c:2753
void CDECL wined3d_stateblock_apply_clear_state(struct wined3d_stateblock *stateblock, struct wined3d_device *device)
Definition: stateblock.c:2917
static struct wined3d_shader * get_ffp_vertex_shader(struct wined3d_device *device, const struct wined3d_state *state)
Definition: stateblock.c:2965
static void wined3d_device_set_light_enable(struct wined3d_device *device, unsigned int light_idx, bool enable)
Definition: stateblock.c:2672
static void transpose_matrix(struct wined3d_matrix *out, const struct wined3d_matrix *m)
Definition: stateblock.c:260
@ WINED3D_RS_STIPPLEDALPHA
Definition: wined3d.h:316
@ WINED3D_RS_WRAPV
Definition: wined3d.h:292
@ WINED3D_RS_TEXTUREPERSPECTIVE
Definition: wined3d.h:290
@ WINED3D_RS_WRAPU
Definition: wined3d.h:291
@ WINED3D_RS_MONOENABLE
Definition: wined3d.h:297
@ WINED3D_RS_PLANEMASK
Definition: wined3d.h:299
@ WINED3D_RS_SUBPIXELX
Definition: wined3d.h:315
@ WINED3D_RS_FLUSHBATCH
Definition: wined3d.h:327
@ WINED3D_RS_ROP2
Definition: wined3d.h:298
@ WINED3D_RS_ANTIALIAS
Definition: wined3d.h:289
@ WINED3D_RS_ANISOTROPY
Definition: wined3d.h:326
@ WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
Definition: wined3d.h:328
@ WINED3D_RS_COLORKEYBLENDENABLE
Definition: wined3d.h:354
@ WINED3D_RS_EXTENTS
Definition: wined3d.h:348
@ WINED3D_RS_SUBPIXEL
Definition: wined3d.h:314
@ WINED3D_RS_MIPMAPLODBIAS
Definition: wined3d.h:324
@ WINED3D_RS_STIPPLEENABLE
Definition: wined3d.h:322
static int wined3d_bit_scan(unsigned int *x)
Definition: wined3d.h:2982
#define WINED3D_MAX_PS_CONSTS_F
Definition: wined3d.h:1605
#define WINED3D_MAX_VS_CONSTS_F
Definition: wined3d.h:1604
wined3d_light_type
Definition: wined3d.h:65
@ WINED3D_LIGHT_SPOT
Definition: wined3d.h:67
@ WINED3D_LIGHT_PARALLELPOINT
Definition: wined3d.h:69
@ WINED3D_LIGHT_POINT
Definition: wined3d.h:66
@ WINED3D_LIGHT_DIRECTIONAL
Definition: wined3d.h:68
@ WINED3D_TSS_CONSTANT
Definition: wined3d.h:611
@ WINED3DFMT_NVDB
Definition: wined3d.h:271
@ WINED3DFMT_ATOC
Definition: wined3d.h:282
#define WINED3D_VERTEX_SAMPLER_OFFSET
Definition: wined3d.h:1037
#define WINED3D_MAX_CONSTS_B
Definition: wined3d.h:1602
@ WINED3D_ZB_USEW
Definition: wined3d.h:475
@ WINED3D_ZB_FALSE
Definition: wined3d.h:473
wined3d_shader_type
Definition: wined3d.h:840
@ WINED3D_SHADER_TYPE_PIXEL
Definition: wined3d.h:841
@ WINED3D_SHADER_TYPE_VERTEX
Definition: wined3d.h:842
#define WINED3D_MAX_CONSTS_I
Definition: wined3d.h:1603
#define WINED3D_LEGACY_FFP_LIGHTING
Definition: wined3d.h:1329
#define WINED3D_SHADER_CONST_PS_BUMP_ENV
@ WINED3D_PUSH_CONSTANTS_PS_FFP
@ WINED3D_PUSH_CONSTANTS_PS_B
@ WINED3D_PUSH_CONSTANTS_VS_B
@ WINED3D_PUSH_CONSTANTS_VS_FFP
@ WINED3D_PUSH_CONSTANTS_VS_I
@ WINED3D_PUSH_CONSTANTS_PS_F
@ WINED3D_PUSH_CONSTANTS_PS_I
@ WINED3D_PUSH_CONSTANTS_VS_F
static BOOL wined3d_bitmap_get_range(const uint32_t *bitmap, unsigned int bit_count, unsigned int start, struct wined3d_range *range)
static void wined3d_vec4_transform(struct wined3d_vec4 *dst, const struct wined3d_vec4 *v, const struct wined3d_matrix *m)
#define WINED3D_SHADER_CONST_FFP_VERTEXBLEND
#define WINED3D_SHADER_CONST_FFP_COLOR_KEY
#define WINED3D_SHADER_CONST_PS_ALPHA_TEST
#define WINED3D_SHADER_CONST_FFP_MODELVIEW
#define WINED3D_SHADER_CONST_FFP_PS
#define WINED3D_SHADER_CONST_FFP_LIGHTS
#define WINED3D_SHADER_CONST_FFP_PROJ
#define WINED3D_FFP_CONSTANTS_EXTRA_REGISTER
#define MAX_VERTEX_BLENDS
static BOOL wined3d_bitmap_is_set(const uint32_t *map, unsigned int idx)
#define WINED3D_SHADER_CONST_FFP_TEXMATRIX
#define WINED3D_SHADER_CONST_VS_POINTSIZE
#define WINED3D_SHADER_CONST_FFP_MATERIAL

Referenced by d3d8_device_DrawIndexedPrimitive(), d3d8_device_DrawIndexedPrimitiveUP(), d3d8_device_DrawPrimitive(), d3d8_device_DrawPrimitiveUP(), d3d9_device_DrawIndexedPrimitive(), d3d9_device_DrawIndexedPrimitiveUP(), d3d9_device_DrawPrimitive(), d3d9_device_DrawPrimitiveUP(), d3d_device_apply_state(), and wined3d_device_process_vertices().

◆ wined3d_device_context_set_light()

static void wined3d_device_context_set_light ( struct wined3d_device_context *  context,
unsigned int  light_idx,
const struct wined3d_light *  light 
)
static

Definition at line 2661 of file stateblock.c.

2663{
2664 struct wined3d_light_info *object = NULL;
2665
2666 if (FAILED(wined3d_light_state_set_light(&context->state->light_state, light_idx, light, &object)))
2667 return;
2668
2670}
void wined3d_device_context_emit_set_light(struct wined3d_device_context *context, const struct wined3d_light_info *light)
Definition: cs.c:2083
static HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, unsigned int light_idx, const struct wined3d_light *params, struct wined3d_light_info **light_info)
Definition: stateblock.c:707

Referenced by wined3d_device_apply_stateblock(), and wined3d_device_set_light_enable().

◆ wined3d_device_set_base_vertex_index()

static void wined3d_device_set_base_vertex_index ( struct wined3d_device *  device,
int  base_index 
)
static

Definition at line 2545 of file stateblock.c.

2546{
2547 TRACE("device %p, base_index %d.\n", device, base_index);
2548
2549 device->cs->c.state->base_vertex_index = base_index;
2550}

Referenced by wined3d_device_apply_stateblock().

◆ wined3d_device_set_clip_plane()

static void wined3d_device_set_clip_plane ( struct wined3d_device *  device,
unsigned int  plane_idx,
const struct wined3d_vec4 *  plane 
)
static

Definition at line 2696 of file stateblock.c.

2698{
2699 struct wined3d_vec4 *clip_planes = device->cs->c.state->clip_planes;
2700
2701 TRACE("device %p, plane_idx %u, plane %p.\n", device, plane_idx, plane);
2702
2703 if (!memcmp(&clip_planes[plane_idx], plane, sizeof(*plane)))
2704 {
2705 TRACE("Application is setting old values over, nothing to do.\n");
2706 return;
2707 }
2708
2709 clip_planes[plane_idx] = *plane;
2710
2712}
void wined3d_device_context_emit_set_clip_plane(struct wined3d_device_context *context, unsigned int plane_idx, const struct wined3d_vec4 *plane)
Definition: cs.c:1961
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807

Referenced by wined3d_device_apply_stateblock().

◆ wined3d_device_set_light_enable()

static void wined3d_device_set_light_enable ( struct wined3d_device *  device,
unsigned int  light_idx,
bool  enable 
)
static

Definition at line 2672 of file stateblock.c.

2673{
2674 struct wined3d_light_state *light_state = &device->cs->c.state->light_state;
2675 struct wined3d_light_info *light_info;
2676
2677 TRACE("device %p, light_idx %u, enable %#x.\n", device, light_idx, enable);
2678
2679 /* Special case - enabling an undefined light creates one with a strict set of parameters. */
2680 if (!(light_info = wined3d_light_state_get_light(light_state, light_idx)))
2681 {
2682 TRACE("Light enabled requested but light not defined, so defining one!\n");
2684
2685 if (!(light_info = wined3d_light_state_get_light(light_state, light_idx)))
2686 {
2687 ERR("Adding default lights has failed dismally.\n");
2688 return;
2689 }
2690 }
2691
2692 if (wined3d_light_state_enable_light(light_state, &device->adapter->d3d_info, light_info, enable))
2694}
void wined3d_device_context_emit_set_light_enable(struct wined3d_device_context *context, unsigned int idx, BOOL enable)
Definition: cs.c:2110
const struct wined3d_light WINED3D_default_light
Definition: device.c:69
GLboolean enable
Definition: glext.h:11120
bool wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info, struct wined3d_light_info *light_info, BOOL enable)
Definition: stateblock.c:803
struct wined3d_light_info * wined3d_light_state_get_light(const struct wined3d_light_state *state, unsigned int idx)
Definition: stateblock.c:687

Referenced by wined3d_device_apply_stateblock().

◆ wined3d_device_set_ps_consts_b()

static void wined3d_device_set_ps_consts_b ( struct wined3d_device *  device,
unsigned int  start_idx,
unsigned int  count,
const BOOL *  constants 
)
static

Definition at line 2603 of file stateblock.c.

2605{
2606 unsigned int i;
2607
2608 TRACE("device %p, start_idx %u, count %u, constants %p.\n", device, start_idx, count, constants);
2609
2610 if (TRACE_ON(d3d))
2611 {
2612 for (i = 0; i < count; ++i)
2613 TRACE("Set BOOL constant %u to %#x.\n", start_idx + i, constants[i]);
2614 }
2615
2618}
#define TRACE_ON(x)
Definition: compat.h:75
#define WINED3D_SHADER_CONST_PS_B

Referenced by wined3d_device_apply_stateblock().

◆ wined3d_device_set_ps_consts_f()

static void wined3d_device_set_ps_consts_f ( struct wined3d_device *  device,
unsigned int  start_idx,
unsigned int  count,
const struct wined3d_vec4 *  constants 
)
static

Definition at line 2637 of file stateblock.c.

2639{
2640 unsigned int i;
2641
2642 TRACE("device %p, start_idx %u, count %u, constants %p.\n", device, start_idx, count, constants);
2643
2644 if (TRACE_ON(d3d))
2645 {
2646 for (i = 0; i < count; ++i)
2647 TRACE("Set vec4 constant %u to %s.\n", start_idx + i, debug_vec4(&constants[i]));
2648 }
2649
2652}
const char * debug_vec4(const struct wined3d_vec4 *v)
Definition: utils.c:4585
#define WINED3D_SHADER_CONST_PS_F

Referenced by wined3d_device_apply_stateblock().

◆ wined3d_device_set_ps_consts_i()

static void wined3d_device_set_ps_consts_i ( struct wined3d_device *  device,
unsigned int  start_idx,
unsigned int  count,
const struct wined3d_ivec4 *  constants 
)
static

Definition at line 2620 of file stateblock.c.

2622{
2623 unsigned int i;
2624
2625 TRACE("device %p, start_idx %u, count %u, constants %p.\n", device, start_idx, count, constants);
2626
2627 if (TRACE_ON(d3d))
2628 {
2629 for (i = 0; i < count; ++i)
2630 TRACE("Set ivec4 constant %u to %s.\n", start_idx + i, debug_ivec4(&constants[i]));
2631 }
2632
2635}
const char * debug_ivec4(const struct wined3d_ivec4 *v)
Definition: utils.c:4569
#define WINED3D_SHADER_CONST_PS_I

Referenced by wined3d_device_apply_stateblock().

◆ wined3d_device_set_render_state()

static void wined3d_device_set_render_state ( struct wined3d_device *  device,
enum wined3d_render_state  state,
unsigned int  value 
)
static

Definition at line 2733 of file stateblock.c.

2735{
2736 if (value == device->cs->c.state->render_states[state])
2737 {
2738 TRACE("Application is setting the old value over, nothing to do.\n");
2739 }
2740 else
2741 {
2742 device->cs->c.state->render_states[state] = value;
2744 }
2745
2747 {
2748 TRACE("RESZ multisampled depth buffer resolve triggered.\n");
2750 }
2751}
void wined3d_device_context_emit_set_render_state(struct wined3d_device_context *context, enum wined3d_render_state state, unsigned int value)
Definition: cs.c:1893
Definition: pdh_main.c:64
static void resolve_depth_buffer(struct wined3d_device *device)
Definition: stateblock.c:2714
#define WINED3D_RESZ_CODE
Definition: wined3d.h:1337

Referenced by wined3d_device_apply_stateblock(), and wined3d_stateblock_apply_clear_state().

◆ wined3d_device_set_texture()

static void wined3d_device_set_texture ( struct wined3d_device *  device,
unsigned int  stage,
struct wined3d_texture *  texture 
)
static

Definition at line 2770 of file stateblock.c.

2772{
2774 struct wined3d_shader_resource_view *srv = NULL, *prev;
2775 struct wined3d_state *state = device->cs->c.state;
2776
2777 TRACE("device %p, stage %u, texture %p.\n", device, stage, texture);
2778
2779 if (stage >= WINED3D_VERTEX_SAMPLER_OFFSET)
2780 {
2783 }
2784
2786 return;
2787
2788 prev = state->shader_resource_view[shader_type][stage];
2789 TRACE("Previous texture %p.\n", prev);
2790
2791 if (srv == prev)
2792 {
2793 TRACE("App is setting the same texture again, nothing to do.\n");
2794 return;
2795 }
2796
2797 state->shader_resource_view[shader_type][stage] = srv;
2798
2799 if (srv)
2802 if (prev)
2804
2805 return;
2806}
void wined3d_device_context_emit_set_texture(struct wined3d_device_context *context, enum wined3d_shader_type shader_type, unsigned int bind_index, struct wined3d_shader_resource_view *view)
Definition: cs.c:1621
struct wined3d_shader_resource_view *CDECL wined3d_texture_acquire_identity_srv(struct wined3d_texture *texture)
Definition: texture.c:4476
ULONG CDECL wined3d_shader_resource_view_incref(struct wined3d_shader_resource_view *view)
Definition: view.c:965

Referenced by wined3d_device_apply_stateblock().

◆ wined3d_device_set_texture_stage_state()

static void wined3d_device_set_texture_stage_state ( struct wined3d_device *  device,
unsigned int  stage,
enum wined3d_texture_stage_state  state,
uint32_t  value 
)
static

Definition at line 2753 of file stateblock.c.

2755{
2756 TRACE("device %p, stage %u, state %s, value %#x.\n",
2758
2759 if (value == device->cs->c.state->texture_states[stage][state])
2760 {
2761 TRACE("Application is setting the old value over, nothing to do.\n");
2762 return;
2763 }
2764
2765 device->cs->c.state->texture_states[stage][state] = value;
2766
2768}
void wined3d_device_context_emit_set_texture_state(struct wined3d_device_context *context, unsigned int stage, enum wined3d_texture_stage_state state, unsigned int value)
Definition: cs.c:1914
const char * debug_d3dtexturestate(enum wined3d_texture_stage_state state)
Definition: utils.c:5214

Referenced by wined3d_device_apply_stateblock().

◆ wined3d_device_set_transform()

static void wined3d_device_set_transform ( struct wined3d_device *  device,
enum wined3d_transform_state  state,
const struct wined3d_matrix *  matrix 
)
static

Definition at line 2808 of file stateblock.c.

2810{
2811 TRACE("device %p, state %s, matrix %p.\n", device, debug_d3dtstype(state), matrix);
2812 TRACE("%.8e %.8e %.8e %.8e\n", matrix->_11, matrix->_12, matrix->_13, matrix->_14);
2813 TRACE("%.8e %.8e %.8e %.8e\n", matrix->_21, matrix->_22, matrix->_23, matrix->_24);
2814 TRACE("%.8e %.8e %.8e %.8e\n", matrix->_31, matrix->_32, matrix->_33, matrix->_34);
2815 TRACE("%.8e %.8e %.8e %.8e\n", matrix->_41, matrix->_42, matrix->_43, matrix->_44);
2816
2817 /* If the new matrix is the same as the current one,
2818 * we cut off any further processing. this seems to be a reasonable
2819 * optimization because as was noticed, some apps (warcraft3 for example)
2820 * tend towards setting the same matrix repeatedly for some reason.
2821 *
2822 * From here on we assume that the new matrix is different, wherever it matters. */
2823 if (!memcmp(&device->cs->c.state->transforms[state], matrix, sizeof(*matrix)))
2824 {
2825 TRACE("The application is setting the same matrix over again.\n");
2826 return;
2827 }
2828
2829 device->cs->c.state->transforms[state] = *matrix;
2831}
void wined3d_device_context_emit_set_transform(struct wined3d_device_context *context, enum wined3d_transform_state state, const struct wined3d_matrix *matrix)
Definition: cs.c:1940
const char * debug_d3dtstype(enum wined3d_transform_state tstype)
Definition: utils.c:5282

Referenced by wined3d_device_apply_stateblock().

◆ wined3d_device_set_vs_consts_b()

static void wined3d_device_set_vs_consts_b ( struct wined3d_device *  device,
unsigned int  start_idx,
unsigned int  count,
const BOOL *  constants 
)
static

Definition at line 2552 of file stateblock.c.

2554{
2555 unsigned int i;
2556
2557 TRACE("device %p, start_idx %u, count %u, constants %p.\n", device, start_idx, count, constants);
2558
2559 if (TRACE_ON(d3d))
2560 {
2561 for (i = 0; i < count; ++i)
2562 TRACE("Set BOOL constant %u to %#x.\n", start_idx + i, constants[i]);
2563 }
2564
2567}
#define WINED3D_SHADER_CONST_VS_B

Referenced by wined3d_device_apply_stateblock().

◆ wined3d_device_set_vs_consts_f()

static void wined3d_device_set_vs_consts_f ( struct wined3d_device *  device,
unsigned int  start_idx,
unsigned int  count,
const struct wined3d_vec4 *  constants 
)
static

Definition at line 2586 of file stateblock.c.

2588{
2589 unsigned int i;
2590
2591 TRACE("device %p, start_idx %u, count %u, constants %p.\n", device, start_idx, count, constants);
2592
2593 if (TRACE_ON(d3d))
2594 {
2595 for (i = 0; i < count; ++i)
2596 TRACE("Set vec4 constant %u to %s.\n", start_idx + i, debug_vec4(&constants[i]));
2597 }
2598
2601}
#define WINED3D_SHADER_CONST_VS_F

Referenced by wined3d_device_apply_stateblock().

◆ wined3d_device_set_vs_consts_i()

static void wined3d_device_set_vs_consts_i ( struct wined3d_device *  device,
unsigned int  start_idx,
unsigned int  count,
const struct wined3d_ivec4 *  constants 
)
static

Definition at line 2569 of file stateblock.c.

2571{
2572 unsigned int i;
2573
2574 TRACE("device %p, start_idx %u, count %u, constants %p.\n", device, start_idx, count, constants);
2575
2576 if (TRACE_ON(d3d))
2577 {
2578 for (i = 0; i < count; ++i)
2579 TRACE("Set ivec4 constant %u to %s.\n", start_idx + i, debug_ivec4(&constants[i]));
2580 }
2581
2584}
#define WINED3D_SHADER_CONST_VS_I

Referenced by wined3d_device_apply_stateblock().

◆ wined3d_light_state_enable_light()

bool wined3d_light_state_enable_light ( struct wined3d_light_state *  state,
const struct wined3d_d3d_info *  d3d_info,
struct wined3d_light_info *  light_info,
BOOL  enable 
)

Definition at line 803 of file stateblock.c.

805{
806 unsigned int light_count, i;
807
808 if (!(light_info->enabled = enable))
809 {
810 if (light_info->glIndex == -1)
811 {
812 TRACE("Light already disabled, nothing to do.\n");
813 return false;
814 }
815
816 state->lights[light_info->glIndex] = NULL;
817 light_info->glIndex = -1;
818 return true;
819 }
820
821 if (light_info->glIndex != -1)
822 {
823 TRACE("Light already enabled, nothing to do.\n");
824 return false;
825 }
826
827 /* Find a free light. */
828 light_count = d3d_info->limits.active_light_count;
829 for (i = 0; i < light_count; ++i)
830 {
831 if (state->lights[i])
832 continue;
833
834 state->lights[i] = light_info;
835 light_info->glIndex = i;
836 return true;
837 }
838
839 /* Our tests show that Windows returns D3D_OK in this situation, even with
840 * D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE devices.
841 * This is consistent among ddraw, d3d8 and d3d9. GetLightEnable returns
842 * TRUE * as well for those lights.
843 *
844 * TODO: Test how this affects rendering. */
845 WARN("Too many concurrently active lights.\n");
846 return false;
847}

Referenced by wined3d_cs_exec_set_light_enable(), wined3d_device_set_light_enable(), and wined3d_stateblock_set_light_enable().

◆ wined3d_light_state_get_light()

struct wined3d_light_info * wined3d_light_state_get_light ( const struct wined3d_light_state *  state,
unsigned int  idx 
)

Definition at line 687 of file stateblock.c.

688{
689 struct rb_entry *entry;
690
691 if (!(entry = rb_get(&state->lights_tree, (void *)(ULONG_PTR)idx)))
692 return NULL;
693
695}
static struct rb_entry * rb_get(const struct rb_tree *tree, const void *key)
Definition: rbtree.h:192
Definition: rbtree.h:30

Referenced by wined3d_cs_exec_set_light(), wined3d_cs_exec_set_light_enable(), wined3d_device_set_light_enable(), wined3d_light_state_set_light(), wined3d_state_record_lights(), wined3d_stateblock_get_light(), wined3d_stateblock_set_light(), and wined3d_stateblock_set_light_enable().

◆ wined3d_light_state_set_light()

static HRESULT wined3d_light_state_set_light ( struct wined3d_light_state *  state,
unsigned int  light_idx,
const struct wined3d_light *  params,
struct wined3d_light_info **  light_info 
)
static

Definition at line 707 of file stateblock.c.

709{
712
713 if (!(object = wined3d_light_state_get_light(state, light_idx)))
714 {
715 TRACE("Adding new light.\n");
716 if (!(object = calloc(1, sizeof(*object))))
717 {
718 ERR("Failed to allocate light info.\n");
719 return E_OUTOFMEMORY;
720 }
721
722 object->glIndex = -1;
723 object->OriginalIndex = light_idx;
724 rb_put(&state->lights_tree, (void *)(ULONG_PTR)light_idx, &object->entry);
725 }
726
727 constants = &object->constants;
728
729 object->OriginalParms = *params;
730
731 /* Initialize the object. */
732 TRACE("Light %u setting to type %#x, diffuse %s, specular %s, ambient %s, "
733 "position {%.8e, %.8e, %.8e}, direction {%.8e, %.8e, %.8e}, "
734 "range %.8e, falloff %.8e, theta %.8e, phi %.8e.\n",
735 light_idx, params->type, debug_color(&params->diffuse),
736 debug_color(&params->specular), debug_color(&params->ambient),
737 params->position.x, params->position.y, params->position.z,
738 params->direction.x, params->direction.y, params->direction.z,
739 params->range, params->falloff, params->theta, params->phi);
740
741 constants->diffuse = params->diffuse;
742 constants->specular = params->specular;
743 constants->ambient = params->ambient;
744
745 constants->range = params->range;
746 constants->falloff = params->falloff;
747 constants->const_att = params->attenuation0;
748 constants->linear_att = params->attenuation1;
749 constants->quad_att = params->attenuation2;
750 constants->cos_half_theta = cosf(params->theta / 2.0f);
751 constants->cos_half_phi = cosf(params->phi / 2.0f);
752
753 switch (params->type)
754 {
756 /* Position */
757 constants->position.x = params->position.x;
758 constants->position.y = params->position.y;
759 constants->position.z = params->position.z;
760 constants->position.w = 1.0f;
761 /* FIXME: Range */
762 break;
763
765 /* Direction */
766 constants->direction.x = -params->direction.x;
767 constants->direction.y = -params->direction.y;
768 constants->direction.z = -params->direction.z;
769 constants->direction.w = 0.0f;
770 break;
771
773 /* Position */
774 constants->position.x = params->position.x;
775 constants->position.y = params->position.y;
776 constants->position.z = params->position.z;
777 constants->position.w = 1.0f;
778
779 /* Direction */
780 constants->direction.x = params->direction.x;
781 constants->direction.y = params->direction.y;
782 constants->direction.z = params->direction.z;
783 constants->direction.w = 0.0f;
784
785 /* FIXME: Range */
786 break;
787
789 constants->position.x = params->position.x;
790 constants->position.y = params->position.y;
791 constants->position.z = params->position.z;
792 constants->position.w = 1.0f;
793 break;
794
795 default:
796 FIXME("Unrecognized params type %#x.\n", params->type);
797 }
798
799 *light_info = object;
800 return WINED3D_OK;
801}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
const char * debug_color(const struct wined3d_color *color)
Definition: utils.c:4561
_ACRTIMP float __cdecl cosf(float)
Definition: cosf.c:13
GLenum const GLfloat * params
Definition: glext.h:5645
#define calloc
Definition: rosglue.h:14

Referenced by wined3d_device_context_set_light(), wined3d_stateblock_set_light(), and wined3d_stateblock_set_light_enable().

◆ wined3d_select_feature_level()

static bool wined3d_select_feature_level ( const struct wined3d_adapter *  adapter,
const enum wined3d_feature_level *  levels,
unsigned int  level_count,
enum wined3d_feature_level *  selected_level 
)
static

Definition at line 2336 of file stateblock.c.

2339{
2340 const struct wined3d_d3d_info *d3d_info = &adapter->d3d_info;
2341 unsigned int i;
2342
2343 for (i = 0; i < level_count; ++i)
2344 {
2345 if (levels[i] && d3d_info->feature_level >= levels[i])
2346 {
2347 *selected_level = levels[i];
2348 return true;
2349 }
2350 }
2351
2352 FIXME_(winediag)("None of the requested D3D feature levels is supported on this GPU "
2353 "with the current shader backend.\n");
2354 return false;
2355}
#define FIXME_(x)
Definition: compat.h:77
return adapter
GLsizei levels
Definition: glext.h:7884
enum wined3d_feature_level feature_level

Referenced by wined3d_state_create().

◆ wined3d_state_create()

HRESULT CDECL wined3d_state_create ( struct wined3d_device *  device,
const enum wined3d_feature_level *  levels,
unsigned int  level_count,
struct wined3d_state **  state 
)

Definition at line 2357 of file stateblock.c.

2359{
2360 enum wined3d_feature_level feature_level;
2361 struct wined3d_state *object;
2362
2363 TRACE("device %p, levels %p, level_count %u, state %p.\n", device, levels, level_count, state);
2364
2365 if (!wined3d_select_feature_level(device->adapter, levels, level_count, &feature_level))
2366 return E_FAIL;
2367
2368 TRACE("Selected feature level %s.\n", wined3d_debug_feature_level(feature_level));
2369
2370 if (!(object = calloc(1, sizeof(*object))))
2371 return E_OUTOFMEMORY;
2372 state_init(object, &device->adapter->d3d_info, WINED3D_STATE_INIT_DEFAULT, feature_level);
2373
2374 *state = object;
2375 return S_OK;
2376}
#define E_FAIL
Definition: ddrawi.h:102
const char * wined3d_debug_feature_level(enum wined3d_feature_level level)
Definition: utils.c:6619
#define S_OK
Definition: intsafe.h:52
enum wined3d_feature_level feature_level
static bool wined3d_select_feature_level(const struct wined3d_adapter *adapter, const enum wined3d_feature_level *levels, unsigned int level_count, enum wined3d_feature_level *selected_level)
Definition: stateblock.c:2336
void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, uint32_t flags, enum wined3d_feature_level feature_level)
Definition: stateblock.c:2324
wined3d_feature_level
Definition: wined3d.h:98

Referenced by d3d11_device_CreateDeviceContextState(), d3d_device_context_state_get_wined3d_state(), wined3d_cs_create(), and wined3d_deferred_context_create().

◆ wined3d_state_destroy()

◆ wined3d_state_get_feature_level()

enum wined3d_feature_level CDECL wined3d_state_get_feature_level ( const struct wined3d_state *  state)

Definition at line 2378 of file stateblock.c.

2379{
2380 TRACE("state %p.\n", state);
2381
2382 return state->feature_level;
2383}

Referenced by d3d11_device_CreateDeviceContextState(), and device_parent_wined3d_device_created().

◆ wined3d_state_record_lights()

static void wined3d_state_record_lights ( struct wined3d_light_state *  dst_state,
const struct wined3d_light_state *  src_state 
)
static

Definition at line 849 of file stateblock.c.

851{
852 const struct wined3d_light_info *src;
853 struct wined3d_light_info *dst;
854
855 /* Lights... For a recorded state block, we just had a chain of actions
856 * to perform, so we need to walk that chain and update any actions which
857 * differ. */
859 {
860 if ((src = wined3d_light_state_get_light(src_state, dst->OriginalIndex)))
861 {
862 dst->OriginalParms = src->OriginalParms;
863
864 if (src->glIndex == -1 && dst->glIndex != -1)
865 {
866 /* Light disabled. */
867 dst_state->lights[dst->glIndex] = NULL;
868 }
869 else if (src->glIndex != -1 && dst->glIndex == -1)
870 {
871 /* Light enabled. */
872 dst_state->lights[src->glIndex] = dst;
873 }
874 dst->glIndex = src->glIndex;
875 }
876 else
877 {
878 /* This can happen if the light was originally created as a
879 * default light for SetLightEnable() while recording. */
880 WARN("Light %u in dst_state %p does not exist in src_state %p.\n",
881 dst->OriginalIndex, dst_state, src_state);
882
883 dst->OriginalParms = WINED3D_default_light;
884 if (dst->glIndex != -1)
885 {
886 dst_state->lights[dst->glIndex] = NULL;
887 dst->glIndex = -1;
888 }
889 }
890 }
891}
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
const struct wined3d_light_info * lights[WINED3D_MAX_ACTIVE_LIGHTS]
struct rb_tree lights_tree

Referenced by wined3d_stateblock_capture().

◆ wined3d_stateblock_apply()

void CDECL wined3d_stateblock_apply ( const struct wined3d_stateblock *  stateblock,
struct wined3d_stateblock *  device_state 
)

Definition at line 1156 of file stateblock.c.

1158{
1159 const struct wined3d_stateblock_state *state = &stateblock->stateblock_state;
1160 struct wined3d_range range;
1161 unsigned int i, start;
1162 uint32_t map;
1163
1164 TRACE("stateblock %p, device_state %p.\n", stateblock, device_state);
1165
1166 if (stateblock->changed.vertexShader)
1168 if (stateblock->changed.pixelShader)
1170
1171 for (start = 0; ; start = range.offset + range.size)
1172 {
1173 if (!wined3d_bitmap_get_range(stateblock->changed.vs_consts_f, WINED3D_MAX_VS_CONSTS_F, start, &range))
1174 break;
1175 wined3d_stateblock_set_vs_consts_f(device_state, range.offset, range.size, &state->vs_consts_f[range.offset]);
1176 }
1177 map = stateblock->changed.vertexShaderConstantsI;
1178 for (start = 0; ; start = range.offset + range.size)
1179 {
1181 break;
1182 wined3d_stateblock_set_vs_consts_i(device_state, range.offset, range.size, &state->vs_consts_i[range.offset]);
1183 }
1184 map = stateblock->changed.vertexShaderConstantsB;
1185 for (start = 0; ; start = range.offset + range.size)
1186 {
1188 break;
1189 wined3d_stateblock_set_vs_consts_b(device_state, range.offset, range.size, &state->vs_consts_b[range.offset]);
1190 }
1191
1192 for (start = 0; ; start = range.offset + range.size)
1193 {
1194 if (!wined3d_bitmap_get_range(stateblock->changed.ps_consts_f, WINED3D_MAX_PS_CONSTS_F, start, &range))
1195 break;
1196 wined3d_stateblock_set_ps_consts_f(device_state, range.offset, range.size, &state->ps_consts_f[range.offset]);
1197 }
1198 map = stateblock->changed.pixelShaderConstantsI;
1199 for (start = 0; ; start = range.offset + range.size)
1200 {
1202 break;
1203 wined3d_stateblock_set_ps_consts_i(device_state, range.offset, range.size, &state->ps_consts_i[range.offset]);
1204 }
1205 map = stateblock->changed.pixelShaderConstantsB;
1206 for (start = 0; ; start = range.offset + range.size)
1207 {
1209 break;
1210 wined3d_stateblock_set_ps_consts_b(device_state, range.offset, range.size, &state->ps_consts_b[range.offset]);
1211 }
1212
1213 if (stateblock->changed.transforms)
1214 {
1215 for (i = 0; i < stateblock->num_contained_transform_states; ++i)
1216 {
1218
1220 }
1221 }
1222
1223 if (stateblock->changed.lights)
1224 {
1225 const struct wined3d_light_info *light;
1226
1227 LIST_FOR_EACH_ENTRY(light, &stateblock->changed.changed_lights, struct wined3d_light_info, changed_entry)
1228 {
1229 wined3d_stateblock_set_light(device_state, light->OriginalIndex, &light->OriginalParms);
1230 wined3d_stateblock_set_light_enable(device_state, light->OriginalIndex, light->glIndex != -1);
1231 }
1232 }
1233
1234 if (stateblock->changed.alpha_to_coverage)
1235 {
1236 device_state->stateblock_state.alpha_to_coverage = state->alpha_to_coverage;
1237 device_state->changed.alpha_to_coverage = 1;
1238 }
1239
1240 /* Render states. */
1241 for (i = 0; i < stateblock->num_contained_render_states; ++i)
1242 {
1243 enum wined3d_render_state rs = stateblock->contained_render_states[i];
1244
1246 }
1247
1248 /* Texture states. */
1249 for (i = 0; i < stateblock->num_contained_tss_states; ++i)
1250 {
1251 DWORD stage = stateblock->contained_tss_states[i].stage;
1252 DWORD texture_state = stateblock->contained_tss_states[i].state;
1253
1255 state->texture_states[stage][texture_state]);
1256 }
1257
1258 /* Sampler states. */
1259 for (i = 0; i < stateblock->num_contained_sampler_states; ++i)
1260 {
1261 DWORD stage = stateblock->contained_sampler_states[i].stage;
1262 DWORD sampler_state = stateblock->contained_sampler_states[i].state;
1263
1265 state->sampler_states[stage][sampler_state]);
1266 }
1267
1268 if (stateblock->changed.indices)
1269 {
1270 wined3d_stateblock_set_index_buffer(device_state, state->index_buffer, state->index_format);
1272 }
1273
1274 if (stateblock->changed.vertexDecl && state->vertex_declaration)
1276
1277 if (stateblock->changed.material)
1279
1280 if (stateblock->changed.viewport)
1282
1283 if (stateblock->changed.scissorRect)
1285
1286 map = stateblock->changed.streamSource;
1287 while (map)
1288 {
1291 state->streams[i].offset, state->streams[i].stride);
1292 }
1293
1294 map = stateblock->changed.streamFreq;
1295 while (map)
1296 {
1299 state->streams[i].frequency | state->streams[i].flags);
1300 }
1301
1302 map = stateblock->changed.textures;
1303 while (map)
1304 {
1307 }
1308
1309 map = stateblock->changed.clipplane;
1310 while (map)
1311 {
1314 }
1315
1316 TRACE("Applied stateblock %p.\n", stateblock);
1317}
GLuint GLenum GLenum transform
Definition: glext.h:9407
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:236
unsigned int num_contained_sampler_states
Definition: stateblock.c:96
unsigned int num_contained_transform_states
Definition: stateblock.c:92
unsigned int contained_render_states[WINEHIGHEST_RENDER_STATE+1]
Definition: stateblock.c:89
unsigned int contained_transform_states[WINED3D_HIGHEST_TRANSFORM_STATE+1]
Definition: stateblock.c:91
struct stage_state contained_tss_states[WINED3D_MAX_FFP_TEXTURES *(WINED3D_HIGHEST_TEXTURE_STATE+1)]
Definition: stateblock.c:93
unsigned int num_contained_tss_states
Definition: stateblock.c:94
struct stage_state contained_sampler_states[WINED3D_MAX_COMBINED_SAMPLERS *WINED3D_HIGHEST_SAMPLER_STATE]
Definition: stateblock.c:95
unsigned int num_contained_render_states
Definition: stateblock.c:90
HRESULT CDECL wined3d_stateblock_set_vs_consts_b(struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, const BOOL *constants)
Definition: stateblock.c:1396
HRESULT CDECL wined3d_stateblock_set_vs_consts_f(struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants)
Definition: stateblock.c:1360
void CDECL wined3d_stateblock_set_vertex_declaration(struct wined3d_stateblock *stateblock, struct wined3d_vertex_declaration *declaration)
Definition: stateblock.c:1571
HRESULT CDECL wined3d_stateblock_set_vs_consts_i(struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants)
Definition: stateblock.c:1376
void CDECL wined3d_stateblock_set_material(struct wined3d_stateblock *stateblock, const struct wined3d_material *material)
Definition: stateblock.c:1891
void CDECL wined3d_stateblock_set_texture(struct wined3d_stateblock *stateblock, UINT stage, struct wined3d_texture *texture)
Definition: stateblock.c:1816
HRESULT CDECL wined3d_stateblock_set_stream_source_freq(struct wined3d_stateblock *stateblock, UINT stream_idx, UINT divider)
Definition: stateblock.c:1966
HRESULT CDECL wined3d_stateblock_set_light(struct wined3d_stateblock *stateblock, UINT light_idx, const struct wined3d_light *light)
Definition: stateblock.c:1996
HRESULT CDECL wined3d_stateblock_set_clip_plane(struct wined3d_stateblock *stateblock, UINT plane_idx, const struct wined3d_vec4 *plane)
Definition: stateblock.c:1875
HRESULT CDECL wined3d_stateblock_set_ps_consts_b(struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, const BOOL *constants)
Definition: stateblock.c:1509
HRESULT CDECL wined3d_stateblock_set_ps_consts_i(struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, const struct wined3d_ivec4 *constants)
Definition: stateblock.c:1489
HRESULT CDECL wined3d_stateblock_set_light_enable(struct wined3d_stateblock *stateblock, UINT light_idx, BOOL enable)
Definition: stateblock.c:2042
void CDECL wined3d_stateblock_set_pixel_shader(struct wined3d_stateblock *stateblock, struct wined3d_shader *shader)
Definition: stateblock.c:1460
HRESULT CDECL wined3d_stateblock_set_ps_consts_f(struct wined3d_stateblock *stateblock, unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants)
Definition: stateblock.c:1473
void CDECL wined3d_stateblock_set_sampler_state(struct wined3d_stateblock *stateblock, UINT sampler_idx, enum wined3d_sampler_state state, unsigned int value)
Definition: stateblock.c:1702
void CDECL wined3d_stateblock_set_vertex_shader(struct wined3d_stateblock *stateblock, struct wined3d_shader *shader)
Definition: stateblock.c:1319
void CDECL wined3d_stateblock_set_transform(struct wined3d_stateblock *stateblock, enum wined3d_transform_state d3dts, const struct wined3d_matrix *matrix)
Definition: stateblock.c:1840
void CDECL wined3d_stateblock_set_index_buffer(struct wined3d_stateblock *stateblock, struct wined3d_buffer *buffer, enum wined3d_format_id format_id)
Definition: stateblock.c:1918
void CDECL wined3d_stateblock_set_render_state(struct wined3d_stateblock *stateblock, enum wined3d_render_state state, unsigned int value)
Definition: stateblock.c:1623
void CDECL wined3d_stateblock_set_scissor_rect(struct wined3d_stateblock *stateblock, const RECT *rect)
Definition: stateblock.c:1910
void CDECL wined3d_stateblock_set_base_vertex_index(struct wined3d_stateblock *stateblock, INT base_index)
Definition: stateblock.c:1932
HRESULT CDECL wined3d_stateblock_set_stream_source(struct wined3d_stateblock *stateblock, UINT stream_idx, struct wined3d_buffer *buffer, UINT offset, UINT stride)
Definition: stateblock.c:1939
void CDECL wined3d_stateblock_set_texture_stage_state(struct wined3d_stateblock *stateblock, UINT stage, enum wined3d_texture_stage_state state, unsigned int value)
Definition: stateblock.c:1718
void CDECL wined3d_stateblock_set_viewport(struct wined3d_stateblock *stateblock, const struct wined3d_viewport *viewport)
Definition: stateblock.c:1900
wined3d_render_state
Definition: wined3d.h:288
wined3d_transform_state
Definition: wined3d.h:666

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

◆ wined3d_stateblock_apply_clear_state()

void CDECL wined3d_stateblock_apply_clear_state ( struct wined3d_stateblock *  stateblock,
struct wined3d_device *  device 
)

Definition at line 2917 of file stateblock.c.

2918{
2919 const struct wined3d_stateblock_state *state = &stateblock->stateblock_state;
2920 struct wined3d_device_context *context = &device->cs->c;
2921
2922 /* Clear state depends on the viewport, scissor rect, and scissor enable. */
2923
2924 if (stateblock->changed.viewport)
2926 if (stateblock->changed.scissorRect)
2928
2929 if (stateblock->changed.rasterizer_state)
2930 {
2931 struct wined3d_rasterizer_state *rasterizer_state;
2933 struct wine_rb_entry *entry;
2934
2935 memset(&desc, 0, sizeof(desc));
2936 desc.fill_mode = state->rs[WINED3D_RS_FILLMODE];
2937 desc.cull_mode = state->rs[WINED3D_RS_CULLMODE];
2938 desc.depth_bias = int_to_float(state->rs[WINED3D_RS_DEPTHBIAS]);
2940 desc.depth_clip = TRUE;
2942 desc.line_antialias = state->rs[WINED3D_RS_ANTIALIASEDLINEENABLE];
2943
2944 if ((entry = wine_rb_get(&device->rasterizer_states, &desc)))
2945 {
2946 rasterizer_state = WINE_RB_ENTRY_VALUE(entry, struct wined3d_rasterizer_state, entry);
2948 }
2950 &wined3d_null_parent_ops, &rasterizer_state)))
2951 {
2953 if (wine_rb_put(&device->rasterizer_states, &desc, &rasterizer_state->entry) == -1)
2954 {
2955 ERR("Failed to insert rasterizer state.\n");
2956 wined3d_rasterizer_state_decref(rasterizer_state);
2957 }
2958 }
2959 }
2960
2961 if (wined3d_bitmap_is_set(stateblock->changed.renderState, WINED3D_RS_SRGBWRITEENABLE))
2963}
void CDECL wined3d_device_context_set_rasterizer_state(struct wined3d_device_context *context, struct wined3d_rasterizer_state *rasterizer_state)
Definition: device.c:2101
HRESULT CDECL wined3d_rasterizer_state_create(struct wined3d_device *device, const struct wined3d_rasterizer_state_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_rasterizer_state **state)
Definition: device.c:470
void CDECL wined3d_device_context_set_viewports(struct wined3d_device_context *context, unsigned int viewport_count, const struct wined3d_viewport *viewports)
Definition: device.c:2124
ULONG CDECL wined3d_rasterizer_state_decref(struct wined3d_rasterizer_state *state)
Definition: device.c:446
void CDECL wined3d_device_context_set_scissor_rects(struct wined3d_device_context *context, unsigned int rect_count, const RECT *rects)
Definition: device.c:2149
struct wine_rb_entry entry

Referenced by d3d8_device_Clear(), d3d9_device_Clear(), d3d9_device_ColorFill(), d3d_device_apply_state(), and wined3d_device_apply_stateblock().

◆ wined3d_stateblock_capture()

void CDECL wined3d_stateblock_capture ( struct wined3d_stateblock *  stateblock,
const struct wined3d_stateblock *  device_state 
)

Definition at line 893 of file stateblock.c.

895{
896 const struct wined3d_stateblock_state *state = &device_state->stateblock_state;
897 struct wined3d_range range;
898 unsigned int i, start;
900
901 TRACE("stateblock %p, device_state %p.\n", stateblock, device_state);
902
903 if (stateblock->changed.vertexShader && stateblock->stateblock_state.vs != state->vs)
904 {
905 TRACE("Updating vertex shader from %p to %p.\n", stateblock->stateblock_state.vs, state->vs);
906
907 if (state->vs)
909 if (stateblock->stateblock_state.vs)
911 stateblock->stateblock_state.vs = state->vs;
912 }
913
914 for (start = 0; ; start = range.offset + range.size)
915 {
916 if (!wined3d_bitmap_get_range(stateblock->changed.vs_consts_f, WINED3D_MAX_VS_CONSTS_F, start, &range))
917 break;
918
919 memcpy(&stateblock->stateblock_state.vs_consts_f[range.offset], &state->vs_consts_f[range.offset],
920 sizeof(*state->vs_consts_f) * range.size);
921 }
922 map = stateblock->changed.vertexShaderConstantsI;
923 for (start = 0; ; start = range.offset + range.size)
924 {
926 break;
927
928 memcpy(&stateblock->stateblock_state.vs_consts_i[range.offset], &state->vs_consts_i[range.offset],
929 sizeof(*state->vs_consts_i) * range.size);
930 }
931 map = stateblock->changed.vertexShaderConstantsB;
932 for (start = 0; ; start = range.offset + range.size)
933 {
935 break;
936
937 memcpy(&stateblock->stateblock_state.vs_consts_b[range.offset], &state->vs_consts_b[range.offset],
938 sizeof(*state->vs_consts_b) * range.size);
939 }
940
941 for (start = 0; ; start = range.offset + range.size)
942 {
943 if (!wined3d_bitmap_get_range(stateblock->changed.ps_consts_f, WINED3D_MAX_PS_CONSTS_F, start, &range))
944 break;
945
946 memcpy(&stateblock->stateblock_state.ps_consts_f[range.offset], &state->ps_consts_f[range.offset],
947 sizeof(*state->ps_consts_f) * range.size);
948 }
949 map = stateblock->changed.pixelShaderConstantsI;
950 for (start = 0; ; start = range.offset + range.size)
951 {
953 break;
954
955 memcpy(&stateblock->stateblock_state.ps_consts_i[range.offset], &state->ps_consts_i[range.offset],
956 sizeof(*state->ps_consts_i) * range.size);
957 }
958 map = stateblock->changed.pixelShaderConstantsB;
959 for (start = 0; ; start = range.offset + range.size)
960 {
962 break;
963
964 memcpy(&stateblock->stateblock_state.ps_consts_b[range.offset], &state->ps_consts_b[range.offset],
965 sizeof(*state->ps_consts_b) * range.size);
966 }
967
968 if (stateblock->changed.transforms)
969 {
970 for (i = 0; i < stateblock->num_contained_transform_states; ++i)
971 {
973
974 TRACE("Updating transform %#x.\n", transform);
975
976 stateblock->stateblock_state.transforms[transform] = state->transforms[transform];
977 }
978 }
979
980 if (stateblock->changed.indices
981 && ((stateblock->stateblock_state.index_buffer != state->index_buffer)
982 || (stateblock->stateblock_state.base_vertex_index != state->base_vertex_index)
983 || (stateblock->stateblock_state.index_format != state->index_format)))
984 {
985 TRACE("Updating index buffer to %p, base vertex index to %d.\n",
986 state->index_buffer, state->base_vertex_index);
987
988 if (state->index_buffer)
989 wined3d_buffer_incref(state->index_buffer);
990 if (stateblock->stateblock_state.index_buffer)
991 wined3d_buffer_decref(stateblock->stateblock_state.index_buffer);
992 stateblock->stateblock_state.index_buffer = state->index_buffer;
993 stateblock->stateblock_state.base_vertex_index = state->base_vertex_index;
994 stateblock->stateblock_state.index_format = state->index_format;
995 }
996
997 if (stateblock->changed.vertexDecl && stateblock->stateblock_state.vertex_declaration != state->vertex_declaration)
998 {
999 TRACE("Updating vertex declaration from %p to %p.\n",
1000 stateblock->stateblock_state.vertex_declaration, state->vertex_declaration);
1001
1002 if (state->vertex_declaration)
1003 wined3d_vertex_declaration_incref(state->vertex_declaration);
1004 if (stateblock->stateblock_state.vertex_declaration)
1005 wined3d_vertex_declaration_decref(stateblock->stateblock_state.vertex_declaration);
1006 stateblock->stateblock_state.vertex_declaration = state->vertex_declaration;
1007 }
1008
1009 if (stateblock->changed.material
1010 && memcmp(&state->material, &stateblock->stateblock_state.material,
1011 sizeof(stateblock->stateblock_state.material)))
1012 {
1013 TRACE("Updating material.\n");
1014
1015 stateblock->stateblock_state.material = state->material;
1016 }
1017
1018 if (stateblock->changed.viewport
1019 && memcmp(&state->viewport, &stateblock->stateblock_state.viewport, sizeof(state->viewport)))
1020 {
1021 TRACE("Updating viewport.\n");
1022
1023 stateblock->stateblock_state.viewport = state->viewport;
1024 }
1025
1026 if (stateblock->changed.scissorRect
1027 && memcmp(&state->scissor_rect, &stateblock->stateblock_state.scissor_rect, sizeof(state->scissor_rect)))
1028 {
1029 TRACE("Updating scissor rect.\n");
1030
1031 stateblock->stateblock_state.scissor_rect = state->scissor_rect;
1032 }
1033
1034 map = stateblock->changed.streamSource;
1035 while (map)
1036 {
1038
1039 if (stateblock->stateblock_state.streams[i].stride != state->streams[i].stride
1040 || stateblock->stateblock_state.streams[i].offset != state->streams[i].offset
1041 || stateblock->stateblock_state.streams[i].buffer != state->streams[i].buffer)
1042 {
1043 TRACE("stateblock %p, stream source %u, buffer %p, stride %u, offset %u.\n",
1044 stateblock, i, state->streams[i].buffer, state->streams[i].stride,
1045 state->streams[i].offset);
1046
1047 stateblock->stateblock_state.streams[i].stride = state->streams[i].stride;
1048 if (stateblock->changed.store_stream_offset)
1049 stateblock->stateblock_state.streams[i].offset = state->streams[i].offset;
1050
1051 if (state->streams[i].buffer)
1052 wined3d_buffer_incref(state->streams[i].buffer);
1053 if (stateblock->stateblock_state.streams[i].buffer)
1054 wined3d_buffer_decref(stateblock->stateblock_state.streams[i].buffer);
1055 stateblock->stateblock_state.streams[i].buffer = state->streams[i].buffer;
1056 }
1057 }
1058
1059 map = stateblock->changed.streamFreq;
1060 while (map)
1061 {
1063
1064 if (stateblock->stateblock_state.streams[i].frequency != state->streams[i].frequency
1065 || stateblock->stateblock_state.streams[i].flags != state->streams[i].flags)
1066 {
1067 TRACE("Updating stream frequency %u to %u flags to %#x.\n",
1068 i, state->streams[i].frequency, state->streams[i].flags);
1069
1070 stateblock->stateblock_state.streams[i].frequency = state->streams[i].frequency;
1071 stateblock->stateblock_state.streams[i].flags = state->streams[i].flags;
1072 }
1073 }
1074
1075 map = stateblock->changed.clipplane;
1076 while (map)
1077 {
1079
1080 if (memcmp(&stateblock->stateblock_state.clip_planes[i], &state->clip_planes[i], sizeof(state->clip_planes[i])))
1081 {
1082 TRACE("Updating clipplane %u.\n", i);
1083 stateblock->stateblock_state.clip_planes[i] = state->clip_planes[i];
1084 }
1085 }
1086
1087 /* Render */
1088 for (i = 0; i < stateblock->num_contained_render_states; ++i)
1089 {
1090 enum wined3d_render_state rs = stateblock->contained_render_states[i];
1091
1092 TRACE("Updating render state %#x to %u.\n", rs, state->rs[rs]);
1093
1094 stateblock->stateblock_state.rs[rs] = state->rs[rs];
1095 }
1096
1097 /* Texture states */
1098 for (i = 0; i < stateblock->num_contained_tss_states; ++i)
1099 {
1100 unsigned int stage = stateblock->contained_tss_states[i].stage;
1101 unsigned int texture_state = stateblock->contained_tss_states[i].state;
1102
1103 TRACE("Updating texturestage state %u, %u to %#x (was %#x).\n", stage, texture_state,
1104 state->texture_states[stage][texture_state],
1105 stateblock->stateblock_state.texture_states[stage][texture_state]);
1106
1107 stateblock->stateblock_state.texture_states[stage][texture_state] = state->texture_states[stage][texture_state];
1108 }
1109
1110 /* Samplers */
1111 map = stateblock->changed.textures;
1112 while (map)
1113 {
1115
1116 TRACE("Updating texture %u to %p (was %p).\n",
1117 i, state->textures[i], stateblock->stateblock_state.textures[i]);
1118
1119 if (state->textures[i])
1120 wined3d_texture_incref(state->textures[i]);
1121 if (stateblock->stateblock_state.textures[i])
1122 wined3d_texture_decref(stateblock->stateblock_state.textures[i]);
1123 stateblock->stateblock_state.textures[i] = state->textures[i];
1124 }
1125
1126 for (i = 0; i < stateblock->num_contained_sampler_states; ++i)
1127 {
1128 unsigned int stage = stateblock->contained_sampler_states[i].stage;
1129 unsigned int sampler_state = stateblock->contained_sampler_states[i].state;
1130
1131 TRACE("Updating sampler state %u, %u to %#x (was %#x).\n", stage, sampler_state,
1132 state->sampler_states[stage][sampler_state],
1133 stateblock->stateblock_state.sampler_states[stage][sampler_state]);
1134
1135 stateblock->stateblock_state.sampler_states[stage][sampler_state] = state->sampler_states[stage][sampler_state];
1136 }
1137
1138 if (stateblock->changed.pixelShader && stateblock->stateblock_state.ps != state->ps)
1139 {
1140 if (state->ps)
1142 if (stateblock->stateblock_state.ps)
1144 stateblock->stateblock_state.ps = state->ps;
1145 }
1146
1147 if (stateblock->changed.lights)
1148 wined3d_state_record_lights(stateblock->stateblock_state.light_state, state->light_state);
1149
1150 if (stateblock->changed.alpha_to_coverage)
1151 stateblock->stateblock_state.alpha_to_coverage = state->alpha_to_coverage;
1152
1153 TRACE("Capture done.\n");
1154}
ULONG CDECL wined3d_buffer_incref(struct wined3d_buffer *buffer)
Definition: buffer.c:248
ULONG CDECL wined3d_shader_incref(struct wined3d_shader *shader)
Definition: shader.c:2535
ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
Definition: texture.c:1606
ULONG CDECL wined3d_texture_incref(struct wined3d_texture *texture)
Definition: texture.c:1516
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static void wined3d_state_record_lights(struct wined3d_light_state *dst_state, const struct wined3d_light_state *src_state)
Definition: stateblock.c:849
ULONG CDECL wined3d_vertex_declaration_incref(struct wined3d_vertex_declaration *declaration)

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

◆ wined3d_stateblock_create()

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

Definition at line 2508 of file stateblock.c.

2510{
2511 struct wined3d_stateblock *object;
2512 HRESULT hr;
2513
2514 TRACE("device %p, device_state %p, type %#x, stateblock %p.\n",
2515 device, device_state, type, stateblock);
2516
2517 if (!(object = calloc(1, sizeof(*object))))
2518 return E_OUTOFMEMORY;
2519
2521 if (FAILED(hr))
2522 {
2523 WARN("Failed to initialize stateblock, hr %#lx.\n", hr);
2524 free(object);
2525 return hr;
2526 }
2527
2528 TRACE("Created stateblock %p.\n", object);
2529 *stateblock = object;
2530
2531 return WINED3D_OK;
2532}
HRESULT hr
Definition: delayimp.cpp:582
static HRESULT stateblock_init(struct wined3d_stateblock *stateblock, const struct wined3d_stateblock *device_state, struct wined3d_device *device, enum wined3d_stateblock_type type)
Definition: stateblock.c:2450

Referenced by d3d8_device_BeginStateBlock(), d3d8_device_CreateStateBlock(), d3d9_device_BeginStateBlock(), d3d_device7_BeginStateBlock(), d3d_device7_CreateStateBlock(), d3d_device_init(), ddraw_set_cooperative_level(), device_init(), and stateblock_init().

◆ wined3d_stateblock_decref()

ULONG CDECL wined3d_stateblock_decref ( struct wined3d_stateblock *  stateblock)

Definition at line 670 of file stateblock.c.

671{
672 unsigned int refcount = InterlockedDecrement(&stateblock->ref);
673
674 TRACE("%p decreasing refcount to %u\n", stateblock, refcount);
675
676 if (!refcount)
677 {
680 free(stateblock);
682 }
683
684 return refcount;
685}
#define InterlockedDecrement
Definition: armddk.h:52
static void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state)
Definition: stateblock.c:588
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_CreateStateBlock(), d3d8_device_DeleteStateBlock(), d3d8_device_EndStateBlock(), d3d8_device_Release(), d3d8_device_Reset(), d3d9_device_EndStateBlock(), d3d9_device_Release(), d3d9_device_reset(), d3d9_stateblock_Release(), d3d_device7_CreateStateBlock(), d3d_device7_DeleteStateBlock(), d3d_device7_EndStateBlock(), d3d_device_init(), d3d_device_inner_Release(), and ddraw_set_cooperative_level().

◆ wined3d_stateblock_depth_buffer_changed()

void CDECL wined3d_stateblock_depth_buffer_changed ( struct wined3d_stateblock *  stateblock)

Definition at line 4043 of file stateblock.c.

4044{
4045 struct wined3d_vertex_declaration *decl = stateblock->stateblock_state.vertex_declaration;
4046
4047 /* The presence of a depth buffer affects depth clipping when drawing RHW.
4048 * The depth buffer is not part of the stateblock, though, so we need a
4049 * separate function to invalidate it.
4050 * We pass this via the projection matrix, but use
4051 * changed->position_transformed to invalidate it. */
4052
4053 if (decl && decl->position_transformed)
4054 stateblock->changed.position_transformed = 1;
4055}

Referenced by d3d8_device_SetRenderTarget(), d3d9_device_SetDepthStencilSurface(), d3d_device_sync_rendertarget(), d3d_device_update_depth_stencil(), and ddraw_surface_delete_attached_surface().

◆ wined3d_stateblock_get_light()

HRESULT CDECL wined3d_stateblock_get_light ( const struct wined3d_stateblock *  stateblock,
UINT  light_idx,
struct wined3d_light *  light,
BOOL *  enabled 
)

Definition at line 2069 of file stateblock.c.

2071{
2072 struct wined3d_light_info *light_info;
2073
2074 if (!(light_info = wined3d_light_state_get_light(&stateblock->light_state, light_idx)))
2075 {
2076 TRACE("Light %u is not defined.\n", light_idx);
2078 }
2079 *light = light_info->OriginalParms;
2080 *enabled = light_info->enabled ? 128 : 0;
2081 return WINED3D_OK;
2082}
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glext.h:7750
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:44

Referenced by d3d8_device_GetLight(), d3d8_device_GetLightEnable(), d3d9_device_GetLight(), d3d9_device_GetLightEnable(), d3d_device7_GetLight(), and d3d_device7_GetLightEnable().

◆ wined3d_stateblock_get_ps_consts_b()

HRESULT CDECL wined3d_stateblock_get_ps_consts_b ( struct wined3d_stateblock *  stateblock,
unsigned int  start_idx,
unsigned int  count,
BOOL *  constants 
)

Definition at line 1556 of file stateblock.c.

1558{
1559 TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n", stateblock, start_idx, count, constants);
1560
1561 if (!constants || start_idx >= WINED3D_MAX_CONSTS_B)
1563
1564 if (count > WINED3D_MAX_CONSTS_B - start_idx)
1565 count = WINED3D_MAX_CONSTS_B - start_idx;
1566
1567 memcpy(constants, &stateblock->stateblock_state.ps_consts_b[start_idx], count * sizeof(*constants));
1568 return WINED3D_OK;
1569}

Referenced by d3d9_device_GetPixelShaderConstantB().

◆ wined3d_stateblock_get_ps_consts_f()

HRESULT CDECL wined3d_stateblock_get_ps_consts_f ( struct wined3d_stateblock *  stateblock,
unsigned int  start_idx,
unsigned int  count,
struct wined3d_vec4 *  constants 
)

Definition at line 1529 of file stateblock.c.

1531{
1532 TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n", stateblock, start_idx, count, constants);
1533
1536
1537 memcpy(constants, &stateblock->stateblock_state.ps_consts_f[start_idx], count * sizeof(*constants));
1538 return WINED3D_OK;
1539}
static bool wined3d_bound_range(unsigned int start, unsigned int count, unsigned int limit)
Definition: wined3d.h:2995

Referenced by d3d8_device_GetPixelShaderConstant(), and d3d9_device_GetPixelShaderConstantF().

◆ wined3d_stateblock_get_ps_consts_i()

HRESULT CDECL wined3d_stateblock_get_ps_consts_i ( struct wined3d_stateblock *  stateblock,
unsigned int  start_idx,
unsigned int  count,
struct wined3d_ivec4 *  constants 
)

Definition at line 1541 of file stateblock.c.

1543{
1544 TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n", stateblock, start_idx, count, constants);
1545
1546 if (!constants || start_idx >= WINED3D_MAX_CONSTS_I)
1548
1549 if (count > WINED3D_MAX_CONSTS_I - start_idx)
1550 count = WINED3D_MAX_CONSTS_I - start_idx;
1551
1552 memcpy(constants, &stateblock->stateblock_state.ps_consts_i[start_idx], count * sizeof(*constants));
1553 return WINED3D_OK;
1554}

Referenced by d3d9_device_GetPixelShaderConstantI().

◆ wined3d_stateblock_get_state()

const struct wined3d_stateblock_state *CDECL wined3d_stateblock_get_state ( const struct wined3d_stateblock *  stateblock)

Definition at line 2064 of file stateblock.c.

2065{
2066 return &stateblock->stateblock_state;
2067}

Referenced by d3d_device_init(), device_init(), and wined3d_device_process_vertices().

◆ wined3d_stateblock_get_vs_consts_b()

HRESULT CDECL wined3d_stateblock_get_vs_consts_b ( struct wined3d_stateblock *  stateblock,
unsigned int  start_idx,
unsigned int  count,
BOOL *  constants 
)

Definition at line 1445 of file stateblock.c.

1447{
1448 TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n", stateblock, start_idx, count, constants);
1449
1450 if (!constants || start_idx >= WINED3D_MAX_CONSTS_B)
1452
1453 if (count > WINED3D_MAX_CONSTS_B - start_idx)
1454 count = WINED3D_MAX_CONSTS_B - start_idx;
1455
1456 memcpy(constants, &stateblock->stateblock_state.vs_consts_b[start_idx], count * sizeof(*constants));
1457 return WINED3D_OK;
1458}

Referenced by d3d9_device_GetVertexShaderConstantB().

◆ wined3d_stateblock_get_vs_consts_f()

HRESULT CDECL wined3d_stateblock_get_vs_consts_f ( struct wined3d_stateblock *  stateblock,
unsigned int  start_idx,
unsigned int  count,
struct wined3d_vec4 *  constants 
)

Definition at line 1416 of file stateblock.c.

1418{
1419 const struct wined3d_d3d_info *d3d_info = &stateblock->device->adapter->d3d_info;
1420
1421 TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n", stateblock, start_idx, count, constants);
1422
1423 if (!constants || !wined3d_bound_range(start_idx, count, d3d_info->limits.vs_uniform_count))
1425
1426 memcpy(constants, &stateblock->stateblock_state.vs_consts_f[start_idx], count * sizeof(*constants));
1427 return WINED3D_OK;
1428}

Referenced by d3d8_device_GetVertexShaderConstant(), and d3d9_device_GetVertexShaderConstantF().

◆ wined3d_stateblock_get_vs_consts_i()

HRESULT CDECL wined3d_stateblock_get_vs_consts_i ( struct wined3d_stateblock *  stateblock,
unsigned int  start_idx,
unsigned int  count,
struct wined3d_ivec4 *  constants 
)

Definition at line 1430 of file stateblock.c.

1432{
1433 TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n", stateblock, start_idx, count, constants);
1434
1435 if (!constants || start_idx >= WINED3D_MAX_CONSTS_I)
1437
1438 if (count > WINED3D_MAX_CONSTS_I - start_idx)
1439 count = WINED3D_MAX_CONSTS_I - start_idx;
1440
1441 memcpy(constants, &stateblock->stateblock_state.vs_consts_i[start_idx], count * sizeof(*constants));
1442 return WINED3D_OK;
1443}

Referenced by d3d9_device_GetVertexShaderConstantI().

◆ wined3d_stateblock_incref()

ULONG CDECL wined3d_stateblock_incref ( struct wined3d_stateblock *  stateblock)

Definition at line 466 of file stateblock.c.

467{
468 unsigned int refcount = InterlockedIncrement(&stateblock->ref);
469
470 TRACE("%p increasing refcount to %u.\n", stateblock, refcount);
471
472 return refcount;
473}
#define InterlockedIncrement
Definition: armddk.h:53

◆ wined3d_stateblock_init_contained_states()

void CDECL wined3d_stateblock_init_contained_states ( struct wined3d_stateblock *  stateblock)

Definition at line 393 of file stateblock.c.

394{
395 unsigned int i, j;
396
397 for (i = 0; i <= WINEHIGHEST_RENDER_STATE >> 5; ++i)
398 {
399 DWORD map = stateblock->changed.renderState[i];
400 for (j = 0; map; map >>= 1, ++j)
401 {
402 if (!(map & 1)) continue;
403
404 stateblock->contained_render_states[stateblock->num_contained_render_states] = (i << 5) | j;
405 ++stateblock->num_contained_render_states;
406 }
407 }
408
409 for (i = 0; i <= WINED3D_HIGHEST_TRANSFORM_STATE >> 5; ++i)
410 {
411 DWORD map = stateblock->changed.transform[i];
412 for (j = 0; map; map >>= 1, ++j)
413 {
414 if (!(map & 1)) continue;
415
416 stateblock->contained_transform_states[stateblock->num_contained_transform_states] = (i << 5) | j;
417 ++stateblock->num_contained_transform_states;
418 }
419 }
420
421 for (i = 0; i < WINED3D_MAX_FFP_TEXTURES; ++i)
422 {
423 DWORD map = stateblock->changed.textureState[i];
424
425 for(j = 0; map; map >>= 1, ++j)
426 {
427 if (!(map & 1)) continue;
428
429 stateblock->contained_tss_states[stateblock->num_contained_tss_states].stage = i;
430 stateblock->contained_tss_states[stateblock->num_contained_tss_states].state = j;
431 ++stateblock->num_contained_tss_states;
432 }
433 }
434
435 for (i = 0; i < WINED3D_MAX_COMBINED_SAMPLERS; ++i)
436 {
437 DWORD map = stateblock->changed.samplerState[i];
438
439 for (j = 0; map; map >>= 1, ++j)
440 {
441 if (!(map & 1)) continue;
442
443 stateblock->contained_sampler_states[stateblock->num_contained_sampler_states].stage = i;
444 stateblock->contained_sampler_states[stateblock->num_contained_sampler_states].state = j;
445 ++stateblock->num_contained_sampler_states;
446 }
447 }
448}

Referenced by d3d8_device_EndStateBlock(), d3d9_device_EndStateBlock(), d3d_device7_EndStateBlock(), and stateblock_init().

◆ wined3d_stateblock_invalidate_initial_states()

static void wined3d_stateblock_invalidate_initial_states ( struct wined3d_stateblock *  stateblock)
static

Definition at line 2435 of file stateblock.c.

2436{
2437 stateblock->changed.ffp_ps_constants = 1;
2438 stateblock->changed.lights = 1;
2439 stateblock->changed.texture_matrices = 1;
2440 stateblock->changed.material = 1;
2441 stateblock->changed.transforms = 1;
2442 memset(stateblock->changed.transform, 0xff, sizeof(stateblock->changed.transform));
2443 stateblock->changed.modelview_matrices = 1;
2444 stateblock->changed.point_scale = 1;
2445 stateblock->changed.ffp_vs_settings = 1;
2446 stateblock->changed.ffp_ps_settings = 1;
2447 stateblock->changed.bumpenv_constants = 1;
2448}

Referenced by stateblock_init(), and wined3d_stateblock_reset().

◆ wined3d_stateblock_multiply_transform()

void CDECL wined3d_stateblock_multiply_transform ( struct wined3d_stateblock *  stateblock,
enum wined3d_transform_state  d3dts,
const struct wined3d_matrix *  matrix 
)

Definition at line 1859 of file stateblock.c.

1861{
1862 struct wined3d_matrix *mat = &stateblock->stateblock_state.transforms[d3dts];
1863
1864 TRACE("stateblock %p, state %s, matrix %p.\n", stateblock, debug_d3dtstype(d3dts), matrix);
1865 TRACE("%.8e %.8e %.8e %.8e\n", matrix->_11, matrix->_12, matrix->_13, matrix->_14);
1866 TRACE("%.8e %.8e %.8e %.8e\n", matrix->_21, matrix->_22, matrix->_23, matrix->_24);
1867 TRACE("%.8e %.8e %.8e %.8e\n", matrix->_31, matrix->_32, matrix->_33, matrix->_34);
1868 TRACE("%.8e %.8e %.8e %.8e\n", matrix->_41, matrix->_42, matrix->_43, matrix->_44);
1869
1871 stateblock->changed.transform[d3dts >> 5] |= 1u << (d3dts & 0x1f);
1872 stateblock->changed.transforms = 1;
1873}
void multiply_matrix(struct wined3d_matrix *dst, const struct wined3d_matrix *src1, const struct wined3d_matrix *src2)
Definition: utils.c:1153
static const MAT2 mat
Definition: font.c:51

Referenced by d3d8_device_MultiplyTransform(), d3d9_device_MultiplyTransform(), and d3d_device7_MultiplyTransform().

◆ wined3d_stateblock_primary_dirtify_all_states()

void CDECL wined3d_stateblock_primary_dirtify_all_states ( struct wined3d_device *  device,
struct wined3d_stateblock *  stateblock 
)

Definition at line 313 of file stateblock.c.

314{
315 struct rb_tree *lights_tree = &stateblock->stateblock_state.light_state->lights_tree;
316 const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
317 struct wined3d_saved_states *states = &stateblock->changed;
319
320 stateblock_savedstates_set_all(states, d3d_info->limits.vs_uniform_count, d3d_info->limits.ps_uniform_count);
321 states->ffp_ps_constants = 1;
322 states->texture_matrices = 1;
323 states->modelview_matrices = 1;
324 states->point_scale = 1;
325 states->ffp_vs_settings = 1;
326 states->ffp_ps_settings = 1;
327 states->rasterizer_state = 1;
328 states->position_transformed = 1;
329
330 list_init(&stateblock->changed.changed_lights);
331 RB_FOR_EACH_ENTRY(light, lights_tree, struct wined3d_light_info, entry)
332 {
333 light->changed = true;
334 list_add_tail(&stateblock->changed.changed_lights, &light->changed_entry);
335 }
336}
uint32_t rasterizer_state
Definition: stateblock.c:69

Referenced by d3d_device_apply_state().

◆ wined3d_stateblock_reset()

void CDECL wined3d_stateblock_reset ( struct wined3d_stateblock *  stateblock)

Definition at line 2534 of file stateblock.c.

2535{
2536 TRACE("stateblock %p.\n", stateblock);
2537
2539 memset(&stateblock->stateblock_state, 0, sizeof(stateblock->stateblock_state));
2540 stateblock->stateblock_state.light_state = &stateblock->light_state;
2543}

Referenced by d3d8_device_Reset(), and d3d9_device_reset().

◆ wined3d_stateblock_set_base_vertex_index()

void CDECL wined3d_stateblock_set_base_vertex_index ( struct wined3d_stateblock *  stateblock,
INT  base_index 
)

Definition at line 1932 of file stateblock.c.

1933{
1934 TRACE("stateblock %p, base_index %d.\n", stateblock, base_index);
1935
1936 stateblock->stateblock_state.base_vertex_index = base_index;
1937}

Referenced by d3d8_device_DrawIndexedPrimitiveUP(), d3d8_device_SetIndices(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_clip_plane()

HRESULT CDECL wined3d_stateblock_set_clip_plane ( struct wined3d_stateblock *  stateblock,
UINT  plane_idx,
const struct wined3d_vec4 *  plane 
)

Definition at line 1875 of file stateblock.c.

1877{
1878 TRACE("stateblock %p, plane_idx %u, plane %p.\n", stateblock, plane_idx, plane);
1879
1880 if (plane_idx >= stateblock->device->adapter->d3d_info.limits.max_clip_distances)
1881 {
1882 TRACE("Application has requested clipplane this device doesn't support.\n");
1884 }
1885
1886 stateblock->stateblock_state.clip_planes[plane_idx] = *plane;
1887 stateblock->changed.clipplane |= 1u << plane_idx;
1888 return S_OK;
1889}

Referenced by d3d8_device_SetClipPlane(), d3d9_device_SetClipPlane(), d3d_device7_SetClipPlane(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_index_buffer()

void CDECL wined3d_stateblock_set_index_buffer ( struct wined3d_stateblock *  stateblock,
struct wined3d_buffer *  buffer,
enum wined3d_format_id  format_id 
)

Definition at line 1918 of file stateblock.c.

1920{
1921 TRACE("stateblock %p, buffer %p, format %s.\n", stateblock, buffer, debug_d3dformat(format_id));
1922
1923 if (buffer)
1925 if (stateblock->stateblock_state.index_buffer)
1926 wined3d_buffer_decref(stateblock->stateblock_state.index_buffer);
1927 stateblock->stateblock_state.index_buffer = buffer;
1928 stateblock->stateblock_state.index_format = format_id;
1929 stateblock->changed.indices = TRUE;
1930}
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:4605
static UINT format_id
Definition: clipboard.c:1455

Referenced by d3d8_device_DrawIndexedPrimitiveUP(), d3d8_device_SetIndices(), d3d9_device_DrawIndexedPrimitiveUP(), d3d9_device_SetIndices(), d3d_device7_DrawIndexedPrimitive(), d3d_device7_DrawIndexedPrimitiveStrided(), d3d_device7_DrawIndexedPrimitiveVB(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_light()

HRESULT CDECL wined3d_stateblock_set_light ( struct wined3d_stateblock *  stateblock,
UINT  light_idx,
const struct wined3d_light *  light 
)

Definition at line 1996 of file stateblock.c.

1998{
1999 struct wined3d_light_info *object = NULL;
2000 HRESULT hr;
2001
2002 TRACE("stateblock %p, light_idx %u, light %p.\n", stateblock, light_idx, light);
2003
2004 /* Check the parameter range. Need for speed most wanted sets junk lights
2005 * which confuse the GL driver. */
2006 if (!light)
2008
2009 switch (light->type)
2010 {
2012 case WINED3D_LIGHT_SPOT:
2014 /* Incorrect attenuation values can cause the gl driver to crash.
2015 * Happens with Need for speed most wanted. */
2016 if (light->attenuation0 < 0.0f || light->attenuation1 < 0.0f || light->attenuation2 < 0.0f)
2017 {
2018 WARN("Attenuation is negative, returning WINED3DERR_INVALIDCALL.\n");
2020 }
2021 break;
2022
2025 /* Ignores attenuation */
2026 break;
2027
2028 default:
2029 WARN("Light type out of range, returning WINED3DERR_INVALIDCALL.\n");
2031 }
2032
2033 if (!(object = wined3d_light_state_get_light(stateblock->stateblock_state.light_state, light_idx))
2034 || light->type != object->OriginalParms.type)
2035 stateblock->changed.ffp_vs_settings = 1;
2036
2037 if (SUCCEEDED(hr = wined3d_light_state_set_light(stateblock->stateblock_state.light_state, light_idx, light, &object)))
2038 set_light_changed(stateblock, object);
2039 return hr;
2040}
static void set_light_changed(struct wined3d_stateblock *stateblock, struct wined3d_light_info *light_info)
Definition: stateblock.c:697
@ WINED3D_LIGHT_GLSPOT
Definition: wined3d.h:70

Referenced by d3d8_device_SetLight(), d3d9_device_SetLight(), d3d_device7_SetLight(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_light_enable()

HRESULT CDECL wined3d_stateblock_set_light_enable ( struct wined3d_stateblock *  stateblock,
UINT  light_idx,
BOOL  enable 
)

Definition at line 2042 of file stateblock.c.

2043{
2044 struct wined3d_light_state *light_state = stateblock->stateblock_state.light_state;
2045 struct wined3d_light_info *light_info;
2046 HRESULT hr;
2047
2048 TRACE("stateblock %p, light_idx %u, enable %#x.\n", stateblock, light_idx, enable);
2049
2050 if (!(light_info = wined3d_light_state_get_light(light_state, light_idx)))
2051 {
2052 if (FAILED(hr = wined3d_light_state_set_light(light_state, light_idx, &WINED3D_default_light, &light_info)))
2053 return hr;
2054 set_light_changed(stateblock, light_info);
2055 }
2056
2057 if (wined3d_light_state_enable_light(light_state, &stateblock->device->adapter->d3d_info, light_info, enable))
2058 set_light_changed(stateblock, light_info);
2059
2060 stateblock->changed.ffp_vs_settings = 1;
2061 return S_OK;
2062}

Referenced by d3d8_device_LightEnable(), d3d9_device_LightEnable(), d3d_device7_LightEnable(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_material()

void CDECL wined3d_stateblock_set_material ( struct wined3d_stateblock *  stateblock,
const struct wined3d_material *  material 
)

Definition at line 1891 of file stateblock.c.

1893{
1894 TRACE("stateblock %p, material %p.\n", stateblock, material);
1895
1896 stateblock->stateblock_state.material = *material;
1897 stateblock->changed.material = TRUE;
1898}

Referenced by d3d8_device_SetMaterial(), d3d9_device_SetMaterial(), d3d_device7_SetMaterial(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_pixel_shader()

void CDECL wined3d_stateblock_set_pixel_shader ( struct wined3d_stateblock *  stateblock,
struct wined3d_shader *  shader 
)

Definition at line 1460 of file stateblock.c.

1461{
1462 TRACE("stateblock %p, shader %p.\n", stateblock, shader);
1463
1464 if (shader)
1466 if (stateblock->stateblock_state.ps)
1468 stateblock->stateblock_state.ps = shader;
1469 stateblock->changed.pixelShader = TRUE;
1470 stateblock->changed.ffp_ps_settings = 1;
1471}

Referenced by d3d8_device_SetPixelShader(), d3d9_device_SetPixelShader(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_ps_consts_b()

HRESULT CDECL wined3d_stateblock_set_ps_consts_b ( struct wined3d_stateblock *  stateblock,
unsigned int  start_idx,
unsigned int  count,
const BOOL *  constants 
)

Definition at line 1509 of file stateblock.c.

1511{
1512 unsigned int i;
1513
1514 TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n",
1515 stateblock, start_idx, count, constants);
1516
1517 if (!constants || start_idx >= WINED3D_MAX_CONSTS_B)
1519
1520 if (count > WINED3D_MAX_CONSTS_B - start_idx)
1521 count = WINED3D_MAX_CONSTS_B - start_idx;
1522
1523 memcpy(&stateblock->stateblock_state.ps_consts_b[start_idx], constants, count * sizeof(*constants));
1524 for (i = start_idx; i < count + start_idx; ++i)
1525 stateblock->changed.pixelShaderConstantsB |= (1u << i);
1526 return WINED3D_OK;
1527}

Referenced by d3d9_device_SetPixelShaderConstantB(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_ps_consts_f()

HRESULT CDECL wined3d_stateblock_set_ps_consts_f ( struct wined3d_stateblock *  stateblock,
unsigned int  start_idx,
unsigned int  count,
const struct wined3d_vec4 *  constants 
)

Definition at line 1473 of file stateblock.c.

1475{
1476 const struct wined3d_d3d_info *d3d_info = &stateblock->device->adapter->d3d_info;
1477
1478 TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n",
1479 stateblock, start_idx, count, constants);
1480
1481 if (!constants || !wined3d_bound_range(start_idx, count, d3d_info->limits.ps_uniform_count))
1483
1484 memcpy(&stateblock->stateblock_state.ps_consts_f[start_idx], constants, count * sizeof(*constants));
1485 wined3d_bitmap_set_bits(stateblock->changed.ps_consts_f, start_idx, count);
1486 return WINED3D_OK;
1487}
static void wined3d_bitmap_set_bits(uint32_t *bitmap, unsigned int start, unsigned int count)
Definition: stateblock.c:1332

Referenced by d3d8_device_SetPixelShaderConstant(), d3d9_device_SetPixelShaderConstantF(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_ps_consts_i()

HRESULT CDECL wined3d_stateblock_set_ps_consts_i ( struct wined3d_stateblock *  stateblock,
unsigned int  start_idx,
unsigned int  count,
const struct wined3d_ivec4 *  constants 
)

Definition at line 1489 of file stateblock.c.

1491{
1492 unsigned int i;
1493
1494 TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n",
1495 stateblock, start_idx, count, constants);
1496
1497 if (!constants || start_idx >= WINED3D_MAX_CONSTS_I)
1499
1500 if (count > WINED3D_MAX_CONSTS_I - start_idx)
1501 count = WINED3D_MAX_CONSTS_I - start_idx;
1502
1503 memcpy(&stateblock->stateblock_state.ps_consts_i[start_idx], constants, count * sizeof(*constants));
1504 for (i = start_idx; i < count + start_idx; ++i)
1505 stateblock->changed.pixelShaderConstantsI |= (1u << i);
1506 return WINED3D_OK;
1507}

Referenced by d3d9_device_SetPixelShaderConstantI(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_render_state()

void CDECL wined3d_stateblock_set_render_state ( struct wined3d_stateblock *  stateblock,
enum wined3d_render_state  state,
unsigned int  value 
)

Definition at line 1623 of file stateblock.c.

1625{
1626 TRACE("stateblock %p, state %s (%#x), value %#x.\n", stateblock, debug_d3drenderstate(state), state, value);
1627
1629 {
1630 WARN("Unhandled render state %#x.\n", state);
1631 return;
1632 }
1633
1634 stateblock->stateblock_state.rs[state] = value;
1635 stateblock->changed.renderState[state >> 5] |= 1u << (state & 0x1f);
1636
1637 switch (state)
1638 {
1641 {
1642 stateblock->changed.alpha_to_coverage = 1;
1643 stateblock->stateblock_state.alpha_to_coverage = (value == WINED3D_ALPHA_TO_COVERAGE_ENABLE);
1644 }
1645 stateblock->changed.point_scale = 1;
1646 break;
1647
1649 stateblock->changed.ffp_ps_constants = 1;
1650 break;
1651
1653 stateblock->changed.modelview_matrices = 1;
1654 stateblock->changed.ffp_vs_settings = 1;
1655 break;
1656
1661 stateblock->changed.point_scale = 1;
1662 break;
1663
1676 stateblock->changed.ffp_vs_settings = 1;
1677 break;
1678
1680 stateblock->changed.ffp_ps_settings = 1;
1681 break;
1682
1684 stateblock->changed.ffp_vs_settings = 1;
1685 stateblock->changed.ffp_ps_constants = 1;
1686 break;
1687
1694 stateblock->changed.rasterizer_state = 1;
1695 break;
1696
1697 default:
1698 break;
1699 }
1700}
const char * debug_d3drenderstate(enum wined3d_render_state state)
Definition: utils.c:5033
#define WINED3D_ALPHA_TO_COVERAGE_ENABLE
#define WINED3D_ALPHA_TO_COVERAGE_DISABLE

Referenced by d3d8_device_Reset(), d3d8_device_SetRenderState(), d3d9_device_reset(), d3d9_device_SetRenderState(), d3d_device7_SetRenderState(), d3d_device_init(), d3d_vertex_buffer7_ProcessVertices(), device_init(), setup_lighting(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_sampler_state()

void CDECL wined3d_stateblock_set_sampler_state ( struct wined3d_stateblock *  stateblock,
UINT  sampler_idx,
enum wined3d_sampler_state  state,
unsigned int  value 
)

Definition at line 1702 of file stateblock.c.

1704{
1705 TRACE("stateblock %p, sampler_idx %u, state %s, value %#x.\n",
1706 stateblock, sampler_idx, debug_d3dsamplerstate(state), value);
1707
1708 if (sampler_idx >= ARRAY_SIZE(stateblock->stateblock_state.sampler_states))
1709 {
1710 WARN("Invalid sampler %u.\n", sampler_idx);
1711 return;
1712 }
1713
1714 stateblock->stateblock_state.sampler_states[sampler_idx][state] = value;
1715 stateblock->changed.samplerState[sampler_idx] |= 1u << state;
1716}
const char * debug_d3dsamplerstate(enum wined3d_sampler_state state)
Definition: utils.c:5169

Referenced by d3d8_device_SetTextureStageState(), d3d9_device_SetSamplerState(), d3d_device7_SetRenderState(), d3d_device7_SetTextureStageState(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_scissor_rect()

void CDECL wined3d_stateblock_set_scissor_rect ( struct wined3d_stateblock *  stateblock,
const RECT *  rect 
)

Definition at line 1910 of file stateblock.c.

1911{
1912 TRACE("stateblock %p, rect %s.\n", stateblock, wine_dbgstr_rect(rect));
1913
1914 stateblock->stateblock_state.scissor_rect = *rect;
1915 stateblock->changed.scissorRect = TRUE;
1916}
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
RECT rect
Definition: combotst.c:67

Referenced by d3d9_device_reset(), d3d9_device_SetScissorRect(), device_reset_viewport_state(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_stream_source()

HRESULT CDECL wined3d_stateblock_set_stream_source ( struct wined3d_stateblock *  stateblock,
UINT  stream_idx,
struct wined3d_buffer *  buffer,
UINT  offset,
UINT  stride 
)

Definition at line 1939 of file stateblock.c.

1941{
1943
1944 TRACE("stateblock %p, stream_idx %u, buffer %p, stride %u.\n",
1945 stateblock, stream_idx, buffer, stride);
1946
1947 if (stream_idx >= WINED3D_MAX_STREAMS)
1948 {
1949 WARN("Stream index %u out of range.\n", stream_idx);
1951 }
1952
1953 stream = &stateblock->stateblock_state.streams[stream_idx];
1954
1955 if (buffer)
1957 if (stream->buffer)
1959 stream->buffer = buffer;
1960 stream->stride = stride;
1961 stream->offset = offset;
1962 stateblock->changed.streamSource |= 1u << stream_idx;
1963 return WINED3D_OK;
1964}
GLsizei stride
Definition: glext.h:5848
GLintptr offset
Definition: glext.h:5920
Definition: parse.h:23

Referenced by d3d8_device_DrawIndexedPrimitiveUP(), d3d8_device_DrawPrimitiveUP(), d3d8_device_ProcessVertices(), d3d8_device_SetStreamSource(), d3d9_device_DrawIndexedPrimitiveUP(), d3d9_device_DrawPrimitiveUP(), d3d9_device_ProcessVertices(), d3d9_device_SetStreamSource(), d3d_device7_DrawIndexedPrimitive(), d3d_device7_DrawIndexedPrimitiveStrided(), d3d_device7_DrawIndexedPrimitiveVB(), d3d_device7_DrawPrimitive(), d3d_device7_DrawPrimitiveStrided(), d3d_device7_DrawPrimitiveVB(), d3d_vertex_buffer7_ProcessVertices(), d3d_vertex_buffer7_Release(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_stream_source_freq()

HRESULT CDECL wined3d_stateblock_set_stream_source_freq ( struct wined3d_stateblock *  stateblock,
UINT  stream_idx,
UINT  divider 
)

Definition at line 1966 of file stateblock.c.

1968{
1970
1971 TRACE("stateblock %p, stream_idx %u, divider %#x.\n", stateblock, stream_idx, divider);
1972
1974 {
1975 WARN("INSTANCEDATA and INDEXEDDATA were set, returning D3DERR_INVALIDCALL.\n");
1977 }
1978 if ((divider & WINED3DSTREAMSOURCE_INSTANCEDATA) && !stream_idx)
1979 {
1980 WARN("INSTANCEDATA used on stream 0, returning D3DERR_INVALIDCALL.\n");
1982 }
1983 if (!divider)
1984 {
1985 WARN("Divider is 0, returning D3DERR_INVALIDCALL.\n");
1987 }
1988
1989 stream = &stateblock->stateblock_state.streams[stream_idx];
1991 stream->frequency = divider & 0x7fffff;
1992 stateblock->changed.streamFreq |= 1u << stream_idx;
1993 return WINED3D_OK;
1994}
#define WINED3DSTREAMSOURCE_INSTANCEDATA
Definition: wined3d.h:1015
#define WINED3DSTREAMSOURCE_INDEXEDDATA
Definition: wined3d.h:1014

Referenced by d3d9_device_SetStreamSourceFreq(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_texture()

void CDECL wined3d_stateblock_set_texture ( struct wined3d_stateblock *  stateblock,
UINT  stage,
struct wined3d_texture *  texture 
)

Definition at line 1816 of file stateblock.c.

1818{
1819 struct wined3d_texture *prev = stateblock->stateblock_state.textures[stage];
1820
1821 TRACE("stateblock %p, stage %u, texture %p.\n", stateblock, stage, texture);
1822
1823 if (stage >= ARRAY_SIZE(stateblock->stateblock_state.textures))
1824 {
1825 WARN("Ignoring invalid stage %u.\n", stage);
1826 return;
1827 }
1828
1829 if (texture)
1831 if (prev)
1833 stateblock->stateblock_state.textures[stage] = texture;
1834 stateblock->changed.textures |= 1u << stage;
1835
1836 if (texture_binding_might_invalidate_fs_settings(stateblock, texture, prev, stage))
1837 stateblock->changed.ffp_ps_settings = 1;
1838}
static bool texture_binding_might_invalidate_fs_settings(const struct wined3d_stateblock *stateblock, const struct wined3d_texture *texture, const struct wined3d_texture *prev, unsigned int stage)
Definition: stateblock.c:1780

Referenced by d3d8_device_SetTexture(), d3d9_device_SetTexture(), d3d_device3_SetRenderState(), d3d_device3_SetTexture(), d3d_device7_SetTexture(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_texture_lod()

unsigned int CDECL wined3d_stateblock_set_texture_lod ( struct wined3d_stateblock *  stateblock,
struct wined3d_texture *  texture,
unsigned int  lod 
)

Definition at line 4004 of file stateblock.c.

4006{
4007 unsigned int old;
4008
4009 TRACE("texture %p, lod %u.\n", texture, lod);
4010
4012
4013 if (old != lod)
4014 {
4015 for (unsigned int i = 0; i < WINED3D_MAX_COMBINED_SAMPLERS; ++i)
4016 {
4017 /* Mark the texture as changed. The next time the appplication
4018 * draws from this texture, wined3d_device_apply_stateblock() will
4019 * recompute the texture LOD.
4020 *
4021 * We only need to do this for the primary stateblock.
4022 * If a recording stateblock uses a texture whose LOD is changed,
4023 * that texture will be invalidated on the primary stateblock
4024 * anyway when the recording stateblock is applied. */
4025 if (stateblock->stateblock_state.textures[i] == texture)
4026 stateblock->changed.textures |= (1u << i);
4027 }
4028 }
4029
4030 return old;
4031}
unsigned int CDECL wined3d_texture_set_lod(struct wined3d_texture *texture, unsigned int lod)
Definition: texture.c:1722
GLint lod
Definition: glext.h:7795

Referenced by d3d8_texture_2d_SetLOD(), d3d8_texture_3d_SetLOD(), d3d8_texture_cube_SetLOD(), d3d9_texture_2d_SetLOD(), d3d9_texture_3d_SetLOD(), and d3d9_texture_cube_SetLOD().

◆ wined3d_stateblock_set_texture_stage_state()

void CDECL wined3d_stateblock_set_texture_stage_state ( struct wined3d_stateblock *  stateblock,
UINT  stage,
enum wined3d_texture_stage_state  state,
unsigned int  value 
)

Definition at line 1718 of file stateblock.c.

1720{
1721 TRACE("stateblock %p, stage %u, state %s, value %#x.\n",
1722 stateblock, stage, debug_d3dtexturestate(state), value);
1723
1725 {
1726 WARN("Invalid state %#x passed.\n", state);
1727 return;
1728 }
1729
1730 if (stage >= WINED3D_MAX_FFP_TEXTURES)
1731 {
1732 WARN("Attempting to set stage %u which is higher than the max stage %u, ignoring.\n",
1733 stage, WINED3D_MAX_FFP_TEXTURES - 1);
1734 return;
1735 }
1736
1737 stateblock->stateblock_state.texture_states[stage][state] = value;
1738 stateblock->changed.textureState[stage] |= 1u << state;
1739
1740 switch (state)
1741 {
1743 stateblock->changed.ffp_ps_constants = 1;
1744 break;
1745
1747 stateblock->changed.ffp_vs_settings = 1;
1748 /* fall through */
1750 stateblock->changed.texture_matrices = 1;
1751 stateblock->changed.ffp_ps_settings = 1;
1752 break;
1753
1763 stateblock->changed.ffp_ps_settings = 1;
1764 break;
1765
1772 stateblock->changed.bumpenv_constants = 1;
1773 break;
1774
1775 default:
1776 break;
1777 }
1778}
#define WINED3D_HIGHEST_TEXTURE_STATE
Definition: wined3d.h:614

Referenced by d3d8_device_SetTextureStageState(), d3d9_device_SetTextureStageState(), d3d_device3_SetRenderState(), d3d_device7_SetTextureStageState(), fixup_texture_alpha_op(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_transform()

void CDECL wined3d_stateblock_set_transform ( struct wined3d_stateblock *  stateblock,
enum wined3d_transform_state  d3dts,
const struct wined3d_matrix *  matrix 
)

Definition at line 1840 of file stateblock.c.

1842{
1843 TRACE("stateblock %p, state %s, matrix %p.\n", stateblock, debug_d3dtstype(d3dts), matrix);
1844 TRACE("%.8e %.8e %.8e %.8e\n", matrix->_11, matrix->_12, matrix->_13, matrix->_14);
1845 TRACE("%.8e %.8e %.8e %.8e\n", matrix->_21, matrix->_22, matrix->_23, matrix->_24);
1846 TRACE("%.8e %.8e %.8e %.8e\n", matrix->_31, matrix->_32, matrix->_33, matrix->_34);
1847 TRACE("%.8e %.8e %.8e %.8e\n", matrix->_41, matrix->_42, matrix->_43, matrix->_44);
1848
1849 stateblock->stateblock_state.transforms[d3dts] = *matrix;
1850 stateblock->changed.transform[d3dts >> 5] |= 1u << (d3dts & 0x1f);
1851 stateblock->changed.transforms = 1;
1852
1853 if (d3dts >= WINED3D_TS_TEXTURE0 && d3dts <= WINED3D_TS_TEXTURE7)
1854 stateblock->changed.texture_matrices = 1;
1855 else if (d3dts == WINED3D_TS_VIEW || d3dts >= WINED3D_TS_WORLD)
1856 stateblock->changed.modelview_matrices = 1;
1857}
@ WINED3D_TS_TEXTURE7
Definition: wined3d.h:676
@ WINED3D_TS_WORLD
Definition: wined3d.h:677

Referenced by d3d8_device_SetTransform(), d3d9_device_SetTransform(), d3d_device1_SetMatrix(), d3d_device3_MultiplyTransform(), d3d_device3_SetTransform(), d3d_device7_SetTransform(), update_clip_space(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_vertex_declaration()

void CDECL wined3d_stateblock_set_vertex_declaration ( struct wined3d_stateblock *  stateblock,
struct wined3d_vertex_declaration *  declaration 
)

Definition at line 1571 of file stateblock.c.

1573{
1574 struct wined3d_vertex_declaration *prev = stateblock->stateblock_state.vertex_declaration;
1575
1576 TRACE("stateblock %p, declaration %p.\n", stateblock, declaration);
1577
1578 if (declaration)
1580 if (prev)
1582 stateblock->stateblock_state.vertex_declaration = declaration;
1583 stateblock->changed.vertexDecl = TRUE;
1584 /* Texture matrices depend on the format of the TEXCOORD attributes. */
1585 /* FIXME: They also depend on whether the draw is pretransformed,
1586 * but that should go away. */
1587 stateblock->changed.texture_matrices = TRUE;
1588
1589 if (declaration && prev)
1590 {
1591 if (!stateblock->stateblock_state.vs)
1592 {
1593 /* Because of settings->texcoords, we have to regenerate the vertex
1594 * shader on a vdecl change if there aren't enough varyings to just
1595 * always output all the texture coordinates.
1596 *
1597 * Likewise, we have to invalidate the shader when using per-vertex
1598 * colours and diffuse/specular attribute presence changes, or when
1599 * normal presence changes. */
1600 if (!stateblock->device->adapter->d3d_info.full_ffp_varyings || declaration->diffuse != prev->diffuse
1601 || (stateblock->stateblock_state.rs[WINED3D_RS_COLORVERTEX] && declaration->specular != prev->specular)
1602 || declaration->normal != prev->normal || declaration->point_size != prev->point_size)
1603 stateblock->changed.ffp_vs_settings = 1;
1604 }
1605
1606 if (declaration->position_transformed != prev->position_transformed)
1607 {
1608 /* We reuse the projection matrix to undo the translation between
1609 * clip coordinates and pixel coordinates, so we need to invalidate
1610 * it here. */
1611 stateblock->changed.ffp_vs_settings = 1;
1612 stateblock->changed.position_transformed = 1;
1613 stateblock->changed.transforms = 1;
1614 }
1615 }
1616 else
1617 {
1618 stateblock->changed.position_transformed = 1;
1619 stateblock->changed.ffp_vs_settings = 1;
1620 }
1621}

Referenced by d3d8_device_SetVertexShader(), d3d9_device_SetFVF(), d3d9_device_SetVertexDeclaration(), d3d_device7_DrawIndexedPrimitive(), d3d_device7_DrawIndexedPrimitiveStrided(), d3d_device7_DrawIndexedPrimitiveVB(), d3d_device7_DrawPrimitive(), d3d_device7_DrawPrimitiveStrided(), d3d_device7_DrawPrimitiveVB(), d3d_vertex_buffer7_ProcessVertices(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_vertex_shader()

void CDECL wined3d_stateblock_set_vertex_shader ( struct wined3d_stateblock *  stateblock,
struct wined3d_shader *  shader 
)

Definition at line 1319 of file stateblock.c.

1320{
1321 TRACE("stateblock %p, shader %p.\n", stateblock, shader);
1322
1323 if (shader)
1325 if (stateblock->stateblock_state.vs)
1327 stateblock->stateblock_state.vs = shader;
1328 stateblock->changed.vertexShader = TRUE;
1329 stateblock->changed.ffp_vs_settings = 1;
1330}

Referenced by d3d8_device_SetVertexShader(), d3d9_device_SetVertexShader(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_viewport()

void CDECL wined3d_stateblock_set_viewport ( struct wined3d_stateblock *  stateblock,
const struct wined3d_viewport *  viewport 
)

Definition at line 1900 of file stateblock.c.

1902{
1903 TRACE("stateblock %p, viewport %p.\n", stateblock, viewport);
1904
1905 stateblock->stateblock_state.viewport = *viewport;
1906 stateblock->changed.viewport = TRUE;
1907 stateblock->changed.point_scale = TRUE;
1908}

Referenced by d3d8_device_SetViewport(), d3d9_device_reset(), d3d9_device_SetViewport(), d3d_device7_SetViewport(), device_reset_viewport_state(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_vs_consts_b()

HRESULT CDECL wined3d_stateblock_set_vs_consts_b ( struct wined3d_stateblock *  stateblock,
unsigned int  start_idx,
unsigned int  count,
const BOOL *  constants 
)

Definition at line 1396 of file stateblock.c.

1398{
1399 unsigned int i;
1400
1401 TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n",
1402 stateblock, start_idx, count, constants);
1403
1404 if (!constants || start_idx >= WINED3D_MAX_CONSTS_B)
1406
1407 if (count > WINED3D_MAX_CONSTS_B - start_idx)
1408 count = WINED3D_MAX_CONSTS_B - start_idx;
1409
1410 memcpy(&stateblock->stateblock_state.vs_consts_b[start_idx], constants, count * sizeof(*constants));
1411 for (i = start_idx; i < count + start_idx; ++i)
1412 stateblock->changed.vertexShaderConstantsB |= (1u << i);
1413 return WINED3D_OK;
1414}

Referenced by d3d9_device_SetVertexShaderConstantB(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_vs_consts_f()

HRESULT CDECL wined3d_stateblock_set_vs_consts_f ( struct wined3d_stateblock *  stateblock,
unsigned int  start_idx,
unsigned int  count,
const struct wined3d_vec4 *  constants 
)

Definition at line 1360 of file stateblock.c.

1362{
1363 const struct wined3d_d3d_info *d3d_info = &stateblock->device->adapter->d3d_info;
1364
1365 TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n",
1366 stateblock, start_idx, count, constants);
1367
1368 if (!constants || !wined3d_bound_range(start_idx, count, d3d_info->limits.vs_uniform_count))
1370
1371 memcpy(&stateblock->stateblock_state.vs_consts_f[start_idx], constants, count * sizeof(*constants));
1372 wined3d_bitmap_set_bits(stateblock->changed.vs_consts_f, start_idx, count);
1373 return WINED3D_OK;
1374}

Referenced by d3d8_device_SetVertexShaderConstant(), d3d9_device_SetVertexShaderConstantF(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_set_vs_consts_i()

HRESULT CDECL wined3d_stateblock_set_vs_consts_i ( struct wined3d_stateblock *  stateblock,
unsigned int  start_idx,
unsigned int  count,
const struct wined3d_ivec4 *  constants 
)

Definition at line 1376 of file stateblock.c.

1378{
1379 unsigned int i;
1380
1381 TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n",
1382 stateblock, start_idx, count, constants);
1383
1384 if (!constants || start_idx >= WINED3D_MAX_CONSTS_I)
1386
1387 if (count > WINED3D_MAX_CONSTS_I - start_idx)
1388 count = WINED3D_MAX_CONSTS_I - start_idx;
1389
1390 memcpy(&stateblock->stateblock_state.vs_consts_i[start_idx], constants, count * sizeof(*constants));
1391 for (i = start_idx; i < count + start_idx; ++i)
1392 stateblock->changed.vertexShaderConstantsI |= (1u << i);
1393 return WINED3D_OK;
1394}

Referenced by d3d9_device_SetVertexShaderConstantI(), and wined3d_stateblock_apply().

◆ wined3d_stateblock_state_cleanup()

static void wined3d_stateblock_state_cleanup ( struct wined3d_stateblock_state *  state)
static

Definition at line 588 of file stateblock.c.

589{
591 struct wined3d_vertex_declaration *decl;
592 struct wined3d_texture *texture;
593 struct wined3d_buffer *buffer;
594 struct wined3d_shader *shader;
595 unsigned int i;
596
597 if ((decl = state->vertex_declaration))
598 {
599 state->vertex_declaration = NULL;
601 }
602
603 for (i = 0; i < WINED3D_MAX_STREAMS; ++i)
604 {
605 if ((buffer = state->streams[i].buffer))
606 {
607 state->streams[i].buffer = NULL;
609 }
610 }
611
612 if ((buffer = state->index_buffer))
613 {
614 state->index_buffer = NULL;
616 }
617
618 if ((shader = state->vs))
619 {
620 state->vs = NULL;
622 }
623
624 if ((shader = state->ps))
625 {
626 state->ps = NULL;
628 }
629
630 for (i = 0; i < WINED3D_MAX_COMBINED_SAMPLERS; ++i)
631 {
632 if ((texture = state->textures[i]))
633 {
634 state->textures[i] = NULL;
636 }
637 }
638
639 RB_FOR_EACH_ENTRY_DESTRUCTOR(light, cursor, &state->light_state->lights_tree, struct wined3d_light_info, entry)
640 {
641 if (light->changed)
642 list_remove(&light->changed_entry);
643 rb_remove(&state->light_state->lights_tree, &light->entry);
644 free(light);
645 }
646}

Referenced by wined3d_stateblock_decref(), and wined3d_stateblock_reset().

◆ wined3d_stateblock_state_init()

static void wined3d_stateblock_state_init ( struct wined3d_stateblock_state *  state,
const struct wined3d_device *  device,
uint32_t  flags 
)
static

Definition at line 2422 of file stateblock.c.

2424{
2425 rb_init(&state->light_state->lights_tree, lights_compare);
2426
2428 stateblock_state_init_default(state, &device->adapter->d3d_info);
2429
2430}
static void stateblock_state_init_default(struct wined3d_stateblock_state *state, const struct wined3d_d3d_info *d3d_info)
Definition: stateblock.c:2393

Referenced by stateblock_init(), and wined3d_stateblock_reset().

◆ wined3d_stateblock_texture_changed()

void CDECL wined3d_stateblock_texture_changed ( struct wined3d_stateblock *  stateblock,
const struct wined3d_texture *  texture 
)

Definition at line 4033 of file stateblock.c.

4035{
4036 for (unsigned int i = 0; i < WINED3D_MAX_COMBINED_SAMPLERS; ++i)
4037 {
4038 if (stateblock->stateblock_state.textures[i] == texture)
4039 stateblock->changed.textures |= (1u << i);
4040 }
4041}

Referenced by ddraw_surface7_SetLOD(), and ddraw_surface_set_wined3d_textures_colour_key().

Variable Documentation

◆ pixel_states_render

const DWORD pixel_states_render[]
static

Definition at line 99 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 200 of file stateblock.c.

Referenced by stateblock_savedstates_set_vertex().

◆ vertex_states_sampler

const DWORD vertex_states_sampler[]
static
Initial value:

Definition at line 255 of file stateblock.c.

Referenced by stateblock_savedstates_set_vertex().

◆ vertex_states_texture

const DWORD vertex_states_texture[]
static