stateblock.c revision 4237d5a79f48789aacc67dc43378d2d7813a39f4
/*
* state block implementation
*
* Copyright 2002 Raphael Junqueira
* Copyright 2004 Jason Edmeades
* Copyright 2005 Oliver Stieber
* Copyright 2007 Stefan Dösinger for CodeWeavers
* Copyright 2009 Henri Verbeet for CodeWeavers
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Oracle elects to use only
* the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
* a choice of LGPL license versions is made available with the language indicating
* that LGPLv2 or any later version may be used, or where a choice of which version
* of the LGPL is applied is otherwise unspecified.
*/
#include "config.h"
#include "wined3d_private.h"
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[] =
{
};
/* Allocates the correct amount of space for pixel and vertex shader constants,
*/
{
/* Allocate space for floating point constants */
return WINED3D_OK;
fail:
ERR("Failed to allocate memory\n");
return E_OUTOFMEMORY;
}
{
}
/* Set all members of a stateblock savedstate to the given value */
static void stateblock_savedstates_set_all(struct wined3d_saved_states *states, DWORD vs_consts, DWORD ps_consts)
{
unsigned int i;
/* Single values */
/* Fixed size arrays */
/* Dynamically sized arrays */
}
static void stateblock_savedstates_set_pixel(struct wined3d_saved_states *states, const DWORD num_constants)
{
DWORD texture_mask = 0;
WORD sampler_mask = 0;
unsigned int i;
for (i = 0; i < sizeof(pixel_states_render) / sizeof(*pixel_states_render); ++i)
{
}
for (i = 0; i < sizeof(pixel_states_texture) / sizeof(*pixel_states_texture); ++i)
for (i = 0; i < sizeof(pixel_states_sampler) / sizeof(*pixel_states_sampler); ++i)
}
static void stateblock_savedstates_set_vertex(struct wined3d_saved_states *states, const DWORD num_constants)
{
DWORD texture_mask = 0;
WORD sampler_mask = 0;
unsigned int i;
for (i = 0; i < sizeof(vertex_states_render) / sizeof(*vertex_states_render); ++i)
{
}
for (i = 0; i < sizeof(vertex_states_texture) / sizeof(*vertex_states_texture); ++i)
for (i = 0; i < sizeof(vertex_states_sampler) / sizeof(*vertex_states_sampler); ++i)
}
{
unsigned int i, j;
for (i = 0; i <= WINEHIGHEST_RENDER_STATE >> 5; ++i)
{
{
if (!(map & 1)) continue;
}
}
for (i = 0; i <= HIGHEST_TRANSFORMSTATE >> 5; ++i)
{
{
if (!(map & 1)) continue;
}
}
{
{
}
}
for (i = 0; i < MAX_CONST_I; ++i)
{
{
}
}
for (i = 0; i < MAX_CONST_B; ++i)
{
{
}
}
{
{
}
}
for (i = 0; i < MAX_CONST_I; ++i)
{
{
}
}
for (i = 0; i < MAX_CONST_B; ++i)
{
{
}
}
for (i = 0; i < MAX_TEXTURES; ++i)
{
{
if (!(map & 1)) continue;
}
}
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
{
{
if (!(map & 1)) continue;
}
}
}
{
unsigned int i;
for (i = 0; i < LIGHTMAP_SIZE; ++i)
{
const struct wined3d_light_info *src_light;
{
}
}
}
{
return refcount;
}
{
struct wined3d_vertex_declaration *decl;
struct wined3d_sampler *sampler;
struct wined3d_texture *texture;
struct wined3d_buffer *buffer;
struct wined3d_shader *shader;
unsigned int i;
{
}
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
{
{
}
}
for (i = 0; i < MAX_STREAM_OUT; ++i)
{
{
}
}
for (i = 0; i < MAX_STREAMS; ++i)
{
{
}
}
{
}
{
}
for (i = 0; i < MAX_CONSTANT_BUFFERS; ++i)
{
{
}
}
for (i = 0; i < MAX_SAMPLER_OBJECTS; ++i)
{
{
}
}
{
}
for (i = 0; i < MAX_CONSTANT_BUFFERS; ++i)
{
{
}
}
for (i = 0; i < MAX_SAMPLER_OBJECTS; ++i)
{
{
}
}
{
}
for (i = 0; i < MAX_SAMPLER_OBJECTS; ++i)
{
{
}
}
for (i = 0; i < MAX_CONSTANT_BUFFERS; ++i)
{
{
}
}
}
{
if (!refcount)
{
int counter;
{
{
}
}
}
return refcount;
}
static void wined3d_state_record_lights(struct wined3d_state *dst_state, const struct wined3d_state *src_state)
{
UINT i;
/* Lights... For a recorded state block, we just had a chain of actions
* to perform, so we need to walk that chain and update any actions which
* differ. */
for (i = 0; i < LIGHTMAP_SIZE; ++i)
{
struct list *e, *f;
{
/* Look up the light in the destination */
{
{
{
/* Light disabled */
}
{
/* Light enabled */
}
break;
}
}
if (!updated)
{
/* This can happen if the light was originally created as a
* default light for SetLightEnable() while recording. */
WARN("Light %u in dst_state %p does not exist in src_state %p.\n",
{
}
}
}
}
}
{
unsigned int i;
if (stateblock->changed.vertexShader && stateblock->state.vertex_shader != src_state->vertex_shader)
{
TRACE("Updating vertex shader from %p to %p\n",
if (src_state->vertex_shader)
}
/* Vertex shader float constants. */
for (i = 0; i < stateblock->num_contained_vs_consts_f; ++i)
{
}
/* Vertex shader integer constants. */
for (i = 0; i < stateblock->num_contained_vs_consts_i; ++i)
{
}
/* Vertex shader boolean constants. */
for (i = 0; i < stateblock->num_contained_vs_consts_b; ++i)
{
TRACE("Setting vs_consts_b[%u] to %s.\n",
}
/* Pixel shader float constants. */
for (i = 0; i < stateblock->num_contained_ps_consts_f; ++i)
{
}
/* Pixel shader integer constants. */
for (i = 0; i < stateblock->num_contained_ps_consts_i; ++i)
{
}
/* Pixel shader boolean constants. */
for (i = 0; i < stateblock->num_contained_ps_consts_b; ++i)
{
TRACE("Setting ps_consts_b[%u] to %s.\n",
}
/* Others + Render & Texture */
for (i = 0; i < stateblock->num_contained_transform_states; ++i)
{
}
{
TRACE("Updating index buffer to %p, base vertex index to %d.\n",
if (src_state->index_buffer)
}
if (stateblock->changed.vertexDecl && stateblock->state.vertex_declaration != src_state->vertex_declaration)
{
TRACE("Updating vertex declaration from %p to %p.\n",
if (src_state->vertex_declaration)
}
{
TRACE("Updating material.\n");
}
{
TRACE("Updating viewport.\n");
}
{
TRACE("Updating scissor rect.\n");
}
{
if (!(map & 1)) continue;
{
TRACE("Updating stream source %u to %p, stride to %u.\n",
}
}
{
if (!(map & 1)) continue;
{
TRACE("Updating stream frequency %u to %u flags to %#x.\n",
}
}
{
if (!(map & 1)) continue;
if (memcmp(&stateblock->state.clip_planes[i], &src_state->clip_planes[i], sizeof(src_state->clip_planes[i])))
{
TRACE("Updating clipplane %u.\n", i);
}
}
/* Render */
for (i = 0; i < stateblock->num_contained_render_states; ++i)
{
}
/* Texture states */
for (i = 0; i < stateblock->num_contained_tss_states; ++i)
{
}
/* Samplers */
{
if (!(map & 1)) continue;
TRACE("Updating texture %u to %p (was %p).\n",
}
for (i = 0; i < stateblock->num_contained_sampler_states; ++i)
{
}
{
if (src_state->pixel_shader)
}
TRACE("Capture done.\n");
}
{
UINT i;
for (i = 0; i < LIGHTMAP_SIZE; ++i)
{
struct list *e;
{
}
}
}
{
unsigned int i;
/* Vertex Shader Constants. */
for (i = 0; i < stateblock->num_contained_vs_consts_f; ++i)
{
}
for (i = 0; i < stateblock->num_contained_vs_consts_i; ++i)
{
}
for (i = 0; i < stateblock->num_contained_vs_consts_b; ++i)
{
}
/* Pixel Shader Constants. */
for (i = 0; i < stateblock->num_contained_ps_consts_f; ++i)
{
}
for (i = 0; i < stateblock->num_contained_ps_consts_i; ++i)
{
}
for (i = 0; i < stateblock->num_contained_ps_consts_b; ++i)
{
}
/* Render states. */
for (i = 0; i < stateblock->num_contained_render_states; ++i)
{
}
/* Texture states. */
for (i = 0; i < stateblock->num_contained_tss_states; ++i)
{
wined3d_device_set_texture_stage_state(device, stage, state, stateblock->state.texture_states[stage][state]);
}
/* Sampler states. */
for (i = 0; i < stateblock->num_contained_sampler_states; ++i)
{
}
/* Transform states. */
for (i = 0; i < stateblock->num_contained_transform_states; ++i)
{
}
{
}
{
wined3d_device_set_index_buffer(device, stateblock->state.index_buffer, stateblock->state.index_format);
}
{
if (map & 1)
}
{
if (map & 1)
}
{
if (!(map & 1)) continue;
}
{
if (!(map & 1)) continue;
}
for (i = 0; i < MAX_TEXTURES - 1; ++i)
{
if (stateblock->device->stateBlock->state.texture_states[i][WINED3D_TSS_COLOR_OP] == WINED3D_TOP_DISABLE)
{
break;
}
}
}
{
union
{
struct wined3d_line_pattern lp;
DWORD d;
} lp;
union {
float f;
DWORD d;
} tmpfloat;
unsigned int i;
struct wined3d_swapchain *swapchain;
struct wined3d_surface *backbuffer;
static const struct wined3d_matrix identity =
{{{
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f,
}}};
memset(stateblock->changed.pixelShaderConstantsF, 0, d3d_info->limits.ps_uniform_count * sizeof(BOOL));
memset(stateblock->changed.vertexShaderConstantsF, 0, d3d_info->limits.vs_uniform_count * sizeof(BOOL));
/* Set some of the defaults for lights, transforms etc */
for (i = 0; i < 256; ++i)
{
}
TRACE("Render states\n");
/* Render states: */
if (device->auto_depth_stencil)
else
tmpfloat.f = 0.0f;
tmpfloat.f = 1.0f;
tmpfloat.f = 1.0f;
tmpfloat.f = 1.0f;
tmpfloat.f = 1.0f;
tmpfloat.f = 1.0f;
tmpfloat.f = 0.0f;
tmpfloat.f = 0.0f;
tmpfloat.f = 1.0f;
tmpfloat.f = 0.0f;
/* states new in d3d9 */
tmpfloat.f = 1.0f;
tmpfloat.f = 0.0f;
tmpfloat.f = 1.0f;
tmpfloat.f = 0.0f;
/* Texture Stage States - Put directly into state block, we will call function below */
for (i = 0; i < MAX_TEXTURES; ++i)
{
TRACE("Setting up default texture states for texture Stage %u.\n", i);
}
/* Sampler states*/
for (i = 0 ; i < MAX_COMBINED_SAMPLERS; ++i)
{
TRACE("Setting up default samplers states for sampler %u.\n", i);
/* TODO: Indicates which element of a multielement texture to use. */
/* TODO: Vertex offset in the presampled displacement map. */
}
{
}
/* check the return values, because the GetBackBuffer call isn't valid for ddraw */
{
{
struct wined3d_resource_desc desc;
/* Set the default scissor rect values */
}
/* Set the default viewport */
}
TRACE("Done.\n");
}
{
unsigned int i;
for (i = 0; i < LIGHTMAP_SIZE; i++)
{
}
/* The WINED3D_SBT_INIT stateblock type is used during initialization to
* produce a placeholder stateblock so other functions called can update a
* state block. */
switch (type)
{
case WINED3D_SBT_ALL:
break;
case WINED3D_SBT_PIXEL_STATE:
break;
case WINED3D_SBT_VERTEX_STATE:
break;
default:
break;
}
return WINED3D_OK;
}
{
struct wined3d_stateblock *object;
TRACE("device %p, type %#x, stateblock %p.\n",
if (!object)
return E_OUTOFMEMORY;
{
return hr;
}
*stateblock = object;
return WINED3D_OK;
}