wined3d: Add a separate function for initializing the "contained_*" fields from the "changed" field.

This commit is contained in:
Henri Verbeet 2009-09-30 10:49:13 +02:00 committed by Alexandre Julliard
parent 5f3425b89b
commit be0b7355fc
3 changed files with 114 additions and 88 deletions

View File

@ -4406,7 +4406,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_BeginStateBlock(IWineD3DDevice *iface)
static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IWineD3DStateBlock** ppStateBlock) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
unsigned int i, j;
IWineD3DStateBlockImpl *object = This->updateStateBlock;
if (!This->isRecordingState) {
@ -4415,93 +4414,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IW
return WINED3DERR_INVALIDCALL;
}
for (i = 0; i <= WINEHIGHEST_RENDER_STATE >> 5; ++i)
{
DWORD map = object->changed.renderState[i];
for (j = 0; map; map >>= 1, ++j)
{
if (!(map & 1)) continue;
object->contained_render_states[object->num_contained_render_states++] = (i << 5) | j;
}
}
for (i = 0; i <= HIGHEST_TRANSFORMSTATE >> 5; ++i)
{
DWORD map = object->changed.transform[i];
for (j = 0; map; map >>= 1, ++j)
{
if (!(map & 1)) continue;
object->contained_transform_states[object->num_contained_transform_states++] = (i << 5) | j;
}
}
for(i = 0; i < GL_LIMITS(vshader_constantsF); i++) {
if(object->changed.vertexShaderConstantsF[i]) {
object->contained_vs_consts_f[object->num_contained_vs_consts_f] = i;
object->num_contained_vs_consts_f++;
}
}
for(i = 0; i < MAX_CONST_I; i++) {
if (object->changed.vertexShaderConstantsI & (1 << i))
{
object->contained_vs_consts_i[object->num_contained_vs_consts_i] = i;
object->num_contained_vs_consts_i++;
}
}
for(i = 0; i < MAX_CONST_B; i++) {
if (object->changed.vertexShaderConstantsB & (1 << i))
{
object->contained_vs_consts_b[object->num_contained_vs_consts_b] = i;
object->num_contained_vs_consts_b++;
}
}
for (i = 0; i < GL_LIMITS(pshader_constantsF); ++i)
{
if (object->changed.pixelShaderConstantsF[i])
{
object->contained_ps_consts_f[object->num_contained_ps_consts_f] = i;
++object->num_contained_ps_consts_f;
}
}
for(i = 0; i < MAX_CONST_I; i++) {
if (object->changed.pixelShaderConstantsI & (1 << i))
{
object->contained_ps_consts_i[object->num_contained_ps_consts_i] = i;
object->num_contained_ps_consts_i++;
}
}
for(i = 0; i < MAX_CONST_B; i++) {
if (object->changed.pixelShaderConstantsB & (1 << i))
{
object->contained_ps_consts_b[object->num_contained_ps_consts_b] = i;
object->num_contained_ps_consts_b++;
}
}
for(i = 0; i < MAX_TEXTURES; i++) {
DWORD map = object->changed.textureState[i];
for(j = 0; map; map >>= 1, ++j)
{
if (!(map & 1)) continue;
object->contained_tss_states[object->num_contained_tss_states].stage = i;
object->contained_tss_states[object->num_contained_tss_states].state = j;
++object->num_contained_tss_states;
}
}
for(i = 0; i < MAX_COMBINED_SAMPLERS; i++){
DWORD map = object->changed.samplerState[i];
for (j = 0; map; map >>= 1, ++j)
{
if (!(map & 1)) continue;
object->contained_sampler_states[object->num_contained_sampler_states].stage = i;
object->contained_sampler_states[object->num_contained_sampler_states].state = j;
++object->num_contained_sampler_states;
}
}
stateblock_init_contained_states(object);
*ppStateBlock = (IWineD3DStateBlock*) object;
This->isRecordingState = FALSE;

View File

@ -228,6 +228,118 @@ static void stateblock_copy_values(IWineD3DStateBlockImpl *dst, const IWineD3DSt
memcpy(dst->pixelShaderConstantF, src->pixelShaderConstantF, sizeof(float) * gl_info->max_pshader_constantsF * 4);
}
void stateblock_init_contained_states(IWineD3DStateBlockImpl *stateblock)
{
const struct wined3d_gl_info *gl_info = &stateblock->wineD3DDevice->adapter->gl_info;
unsigned int i, j;
for (i = 0; i <= WINEHIGHEST_RENDER_STATE >> 5; ++i)
{
DWORD map = stateblock->changed.renderState[i];
for (j = 0; map; map >>= 1, ++j)
{
if (!(map & 1)) continue;
stateblock->contained_render_states[stateblock->num_contained_render_states] = (i << 5) | j;
++stateblock->num_contained_render_states;
}
}
for (i = 0; i <= HIGHEST_TRANSFORMSTATE >> 5; ++i)
{
DWORD map = stateblock->changed.transform[i];
for (j = 0; map; map >>= 1, ++j)
{
if (!(map & 1)) continue;
stateblock->contained_transform_states[stateblock->num_contained_transform_states] = (i << 5) | j;
++stateblock->num_contained_transform_states;
}
}
for (i = 0; i < gl_info->max_vshader_constantsF; ++i)
{
if (stateblock->changed.vertexShaderConstantsF[i])
{
stateblock->contained_vs_consts_f[stateblock->num_contained_vs_consts_f] = i;
++stateblock->num_contained_vs_consts_f;
}
}
for (i = 0; i < MAX_CONST_I; ++i)
{
if (stateblock->changed.vertexShaderConstantsI & (1 << i))
{
stateblock->contained_vs_consts_i[stateblock->num_contained_vs_consts_i] = i;
++stateblock->num_contained_vs_consts_i;
}
}
for (i = 0; i < MAX_CONST_B; ++i)
{
if (stateblock->changed.vertexShaderConstantsB & (1 << i))
{
stateblock->contained_vs_consts_b[stateblock->num_contained_vs_consts_b] = i;
++stateblock->num_contained_vs_consts_b;
}
}
for (i = 0; i < gl_info->max_pshader_constantsF; ++i)
{
if (stateblock->changed.pixelShaderConstantsF[i])
{
stateblock->contained_ps_consts_f[stateblock->num_contained_ps_consts_f] = i;
++stateblock->num_contained_ps_consts_f;
}
}
for (i = 0; i < MAX_CONST_I; ++i)
{
if (stateblock->changed.pixelShaderConstantsI & (1 << i))
{
stateblock->contained_ps_consts_i[stateblock->num_contained_ps_consts_i] = i;
++stateblock->num_contained_ps_consts_i;
}
}
for (i = 0; i < MAX_CONST_B; ++i)
{
if (stateblock->changed.pixelShaderConstantsB & (1 << i))
{
stateblock->contained_ps_consts_b[stateblock->num_contained_ps_consts_b] = i;
++stateblock->num_contained_ps_consts_b;
}
}
for (i = 0; i < MAX_TEXTURES; ++i)
{
DWORD map = stateblock->changed.textureState[i];
for(j = 0; map; map >>= 1, ++j)
{
if (!(map & 1)) continue;
stateblock->contained_tss_states[stateblock->num_contained_tss_states].stage = i;
stateblock->contained_tss_states[stateblock->num_contained_tss_states].state = j;
++stateblock->num_contained_tss_states;
}
}
for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
{
DWORD map = stateblock->changed.samplerState[i];
for (j = 0; map; map >>= 1, ++j)
{
if (!(map & 1)) continue;
stateblock->contained_sampler_states[stateblock->num_contained_sampler_states].stage = i;
stateblock->contained_sampler_states[stateblock->num_contained_sampler_states].state = j;
++stateblock->num_contained_sampler_states;
}
}
}
/**********************************************************
* IWineD3DStateBlockImpl IUnknown parts follows
**********************************************************/

View File

@ -2354,6 +2354,7 @@ struct IWineD3DStateBlockImpl
HRESULT stateblock_init(IWineD3DStateBlockImpl *stateblock, IWineD3DDeviceImpl *device,
WINED3DSTATEBLOCKTYPE type, IUnknown *parent) DECLSPEC_HIDDEN;
void stateblock_init_contained_states(IWineD3DStateBlockImpl *object) DECLSPEC_HIDDEN;
/* Direct3D terminology with little modifications. We do not have an issued state
* because only the driver knows about it, but we have a created state because d3d