d3d10: Implement D3D10StateBlockMaskGetSetting().

oldstable
Henri Verbeet 2011-11-16 20:08:04 +01:00 committed by Alexandre Julliard
parent c7feb3a533
commit 380f989c4a
4 changed files with 108 additions and 1 deletions

View File

@ -24,6 +24,6 @@
@ stdcall D3D10StateBlockMaskDisableCapture(ptr long long long)
@ stdcall D3D10StateBlockMaskEnableAll(ptr)
@ stdcall D3D10StateBlockMaskEnableCapture(ptr long long long)
@ stub D3D10StateBlockMaskGetSetting
@ stdcall D3D10StateBlockMaskGetSetting(ptr long long)
@ stub D3D10StateBlockMaskIntersect
@ stub D3D10StateBlockMaskUnion

View File

@ -144,6 +144,14 @@ HRESULT WINAPI D3D10CreateStateBlock(ID3D10Device *device,
return S_OK;
}
static BOOL stateblock_mask_get_bit(BYTE *field, UINT field_size, UINT idx)
{
if (idx >= field_size)
return FALSE;
return field[idx >> 3] & (1 << (idx & 7));
}
static HRESULT stateblock_mask_set_bits(BYTE *field, UINT field_size, UINT start_bit, UINT count)
{
UINT end_bit = start_bit + count;
@ -402,3 +410,78 @@ HRESULT WINAPI D3D10StateBlockMaskEnableCapture(D3D10_STATE_BLOCK_MASK *mask,
return E_INVALIDARG;
}
}
BOOL WINAPI D3D10StateBlockMaskGetSetting(D3D10_STATE_BLOCK_MASK *mask,
D3D10_DEVICE_STATE_TYPES state_type, UINT idx)
{
TRACE("mask %p state_type %s, idx %u.\n",
mask, debug_d3d10_device_state_types(state_type), idx);
if (!mask)
return FALSE;
switch (state_type)
{
case D3D10_DST_SO_BUFFERS:
return stateblock_mask_get_bit(&mask->SOBuffers, 1, idx);
case D3D10_DST_OM_RENDER_TARGETS:
return stateblock_mask_get_bit(&mask->OMRenderTargets, 1, idx);
case D3D10_DST_DEPTH_STENCIL_STATE:
return stateblock_mask_get_bit(&mask->OMDepthStencilState, 1, idx);
case D3D10_DST_BLEND_STATE:
return stateblock_mask_get_bit(&mask->OMBlendState, 1, idx);
case D3D10_DST_VS:
return stateblock_mask_get_bit(&mask->VS, 1, idx);
case D3D10_DST_VS_SAMPLERS:
return stateblock_mask_get_bit(mask->VSSamplers,
D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, idx);
case D3D10_DST_VS_SHADER_RESOURCES:
return stateblock_mask_get_bit(mask->VSShaderResources,
D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, idx);
case D3D10_DST_VS_CONSTANT_BUFFERS:
return stateblock_mask_get_bit(mask->VSConstantBuffers,
D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, idx);
case D3D10_DST_GS:
return stateblock_mask_get_bit(&mask->GS, 1, idx);
case D3D10_DST_GS_SAMPLERS:
return stateblock_mask_get_bit(mask->GSSamplers,
D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, idx);
case D3D10_DST_GS_SHADER_RESOURCES:
return stateblock_mask_get_bit(mask->GSShaderResources,
D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, idx);
case D3D10_DST_GS_CONSTANT_BUFFERS:
return stateblock_mask_get_bit(mask->GSConstantBuffers,
D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, idx);
case D3D10_DST_PS:
return stateblock_mask_get_bit(&mask->PS, 1, idx);
case D3D10_DST_PS_SAMPLERS:
return stateblock_mask_get_bit(mask->PSSamplers,
D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, idx);
case D3D10_DST_PS_SHADER_RESOURCES:
return stateblock_mask_get_bit(mask->PSShaderResources,
D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, idx);
case D3D10_DST_PS_CONSTANT_BUFFERS:
return stateblock_mask_get_bit(mask->PSConstantBuffers,
D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, idx);
case D3D10_DST_IA_VERTEX_BUFFERS:
return stateblock_mask_get_bit(mask->IAVertexBuffers,
D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, idx);
case D3D10_DST_IA_INDEX_BUFFER:
return stateblock_mask_get_bit(&mask->IAIndexBuffer, 1, idx);
case D3D10_DST_IA_INPUT_LAYOUT:
return stateblock_mask_get_bit(&mask->IAInputLayout, 1, idx);
case D3D10_DST_IA_PRIMITIVE_TOPOLOGY:
return stateblock_mask_get_bit(&mask->IAPrimitiveTopology, 1, idx);
case D3D10_DST_RS_VIEWPORTS:
return stateblock_mask_get_bit(&mask->RSViewports, 1, idx);
case D3D10_DST_RS_SCISSOR_RECTS:
return stateblock_mask_get_bit(&mask->RSScissorRects, 1, idx);
case D3D10_DST_RS_RASTERIZER_STATE:
return stateblock_mask_get_bit(&mask->RSRasterizerState, 1, idx);
case D3D10_DST_PREDICATION:
return stateblock_mask_get_bit(&mask->Predication, 1, idx);
default:
FIXME("Unhandled state_type %#x.\n", state_type);
return FALSE;
}
}

View File

@ -94,6 +94,7 @@ static void test_stateblock_mask(void)
};
D3D10_STATE_BLOCK_MASK mask_x, mask_y, result;
HRESULT hr;
BOOL ret;
UINT i;
memset(&mask_x, 0, sizeof(mask_x));
@ -176,6 +177,27 @@ static void test_stateblock_mask(void)
result.VSShaderResources[2], result.VSShaderResources[3],
result.VSShaderResources[4], i);
}
result.VS = 0xff;
ret = D3D10StateBlockMaskGetSetting(&result, D3D10_DST_VS, 0);
ok(ret == 1, "Got unexpected ret %#x.\n", ret);
ret = D3D10StateBlockMaskGetSetting(&result, D3D10_DST_VS, 1);
ok(!ret, "Got unexpected ret %#x.\n", ret);
result.VS = 0xfe;
ret = D3D10StateBlockMaskGetSetting(&result, D3D10_DST_VS, 0);
ok(!ret, "Got unexpected ret %#x.\n", ret);
result.VS = 0;
ret = D3D10StateBlockMaskGetSetting(&result, D3D10_DST_VS, 0);
ok(!ret, "Got unexpected ret %#x.\n", ret);
memset(&result, 0xff, sizeof(result));
ret = D3D10StateBlockMaskGetSetting(&result, D3D10_DST_VS_SHADER_RESOURCES, 3);
ok(ret == 8, "Got unexpected ret %#x.\n", ret);
ret = D3D10StateBlockMaskGetSetting(&result, D3D10_DST_VS_SHADER_RESOURCES,
D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT);
ok(!ret, "Got unexpected ret %#x.\n", ret);
memset(&result, 0, sizeof(result));
ret = D3D10StateBlockMaskGetSetting(&result, D3D10_DST_VS_SHADER_RESOURCES, 3);
ok(!ret, "Got unexpected ret %#x.\n", ret);
}
START_TEST(device)

View File

@ -840,6 +840,8 @@ HRESULT WINAPI D3D10StateBlockMaskDisableCapture(D3D10_STATE_BLOCK_MASK *mask,
HRESULT WINAPI D3D10StateBlockMaskEnableAll(D3D10_STATE_BLOCK_MASK *mask);
HRESULT WINAPI D3D10StateBlockMaskEnableCapture(D3D10_STATE_BLOCK_MASK *mask,
D3D10_DEVICE_STATE_TYPES state_type, UINT start_idx, UINT count);
BOOL WINAPI D3D10StateBlockMaskGetSetting(D3D10_STATE_BLOCK_MASK *mask,
D3D10_DEVICE_STATE_TYPES state_type, UINT idx);
#ifdef __cplusplus
}