Commit 5323042f authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Add helpers to retrieve shader constants from a wined3d_stateblock.

parent 31eacea3
......@@ -3051,26 +3051,15 @@ static HRESULT WINAPI d3d8_device_GetVertexShaderConstant(IDirect3DDevice8 *ifac
DWORD start_idx, void *constants, DWORD count)
{
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
const struct wined3d_vec4 *src;
HRESULT hr;
TRACE("iface %p, start_idx %lu, constants %p, count %lu.\n", iface, start_idx, constants, count);
if (!constants)
return D3DERR_INVALIDCALL;
if (!wined3d_bound_range(start_idx, count, device->vs_uniform_count))
{
WARN("Trying to access %lu constants, but d3d8 only supports %u.\n",
start_idx + count, device->vs_uniform_count);
return D3DERR_INVALIDCALL;
}
wined3d_mutex_lock();
src = device->stateblock_state->vs_consts_f;
memcpy(constants, &src[start_idx], count * sizeof(*src));
hr = wined3d_stateblock_get_vs_consts_f(device->state, start_idx, count, constants);
wined3d_mutex_unlock();
return D3D_OK;
return hr;
}
static HRESULT WINAPI d3d8_device_GetVertexShaderDeclaration(IDirect3DDevice8 *iface,
......@@ -3353,19 +3342,18 @@ static HRESULT WINAPI d3d8_device_GetPixelShaderConstant(IDirect3DDevice8 *iface
DWORD start_idx, void *constants, DWORD count)
{
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
const struct wined3d_vec4 *src;
HRESULT hr;
TRACE("iface %p, start_idx %lu, constants %p, count %lu.\n", iface, start_idx, constants, count);
if (!constants || !wined3d_bound_range(start_idx, count, D3D8_MAX_PIXEL_SHADER_CONSTANTF))
if (!wined3d_bound_range(start_idx, count, D3D8_MAX_PIXEL_SHADER_CONSTANTF))
return WINED3DERR_INVALIDCALL;
wined3d_mutex_lock();
src = device->stateblock_state->ps_consts_f;
memcpy(constants, &src[start_idx], count * sizeof(*src));
hr = wined3d_stateblock_get_ps_consts_f(device->state, start_idx, count, constants);
wined3d_mutex_unlock();
return D3D_OK;
return hr;
}
static HRESULT WINAPI d3d8_device_GetPixelShaderFunction(IDirect3DDevice8 *iface,
......
......@@ -3678,26 +3678,15 @@ static HRESULT WINAPI d3d9_device_GetVertexShaderConstantF(IDirect3DDevice9Ex *i
UINT start_idx, float *constants, UINT count)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
const struct wined3d_vec4 *src;
HRESULT hr;
TRACE("iface %p, start_idx %u, constants %p, count %u.\n", iface, start_idx, constants, count);
if (!constants)
return D3DERR_INVALIDCALL;
if (!wined3d_bound_range(start_idx, count, device->vs_uniform_count))
{
WARN("Trying to access %u constants, but d3d9 only supports %u\n",
start_idx + count, device->vs_uniform_count);
return D3DERR_INVALIDCALL;
}
wined3d_mutex_lock();
src = device->stateblock_state->vs_consts_f;
memcpy(constants, &src[start_idx], count * sizeof(*src));
hr = wined3d_stateblock_get_vs_consts_f(device->state, start_idx, count, (struct wined3d_vec4 *)constants);
wined3d_mutex_unlock();
return D3D_OK;
return hr;
}
static HRESULT WINAPI d3d9_device_SetVertexShaderConstantI(IDirect3DDevice9Ex *iface,
......@@ -3720,21 +3709,15 @@ static HRESULT WINAPI d3d9_device_GetVertexShaderConstantI(IDirect3DDevice9Ex *i
UINT start_idx, int *constants, UINT count)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
const struct wined3d_ivec4 *src;
HRESULT hr;
TRACE("iface %p, start_idx %u, constants %p, count %u.\n", iface, start_idx, constants, count);
if (!constants || start_idx >= WINED3D_MAX_CONSTS_I)
return WINED3DERR_INVALIDCALL;
if (count > WINED3D_MAX_CONSTS_I - start_idx)
count = WINED3D_MAX_CONSTS_I - start_idx;
wined3d_mutex_lock();
src = device->stateblock_state->vs_consts_i;
memcpy(constants, &src[start_idx], count * sizeof(*src));
hr = wined3d_stateblock_get_vs_consts_i(device->state, start_idx, count, (struct wined3d_ivec4 *)constants);
wined3d_mutex_unlock();
return D3D_OK;
return hr;
}
static HRESULT WINAPI d3d9_device_SetVertexShaderConstantB(IDirect3DDevice9Ex *iface,
......@@ -3756,19 +3739,15 @@ static HRESULT WINAPI d3d9_device_GetVertexShaderConstantB(IDirect3DDevice9Ex *i
UINT start_idx, BOOL *constants, UINT count)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, start_idx %u, constants %p, count %u.\n", iface, start_idx, constants, count);
if (!constants || start_idx >= WINED3D_MAX_CONSTS_B)
return WINED3DERR_INVALIDCALL;
if (count > WINED3D_MAX_CONSTS_B - start_idx)
count = WINED3D_MAX_CONSTS_B - start_idx;
wined3d_mutex_lock();
memcpy(constants, &device->stateblock_state->vs_consts_b[start_idx], count * sizeof(*constants));
hr = wined3d_stateblock_get_vs_consts_b(device->state, start_idx, count, constants);
wined3d_mutex_unlock();
return D3D_OK;
return hr;
}
static HRESULT WINAPI d3d9_device_SetStreamSource(IDirect3DDevice9Ex *iface,
......@@ -4028,19 +4007,15 @@ static HRESULT WINAPI d3d9_device_GetPixelShaderConstantF(IDirect3DDevice9Ex *if
UINT start_idx, float *constants, UINT count)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
const struct wined3d_vec4 *src;
HRESULT hr;
TRACE("iface %p, start_idx %u, constants %p, count %u.\n", iface, start_idx, constants, count);
if (!constants || !wined3d_bound_range(start_idx, count, WINED3D_MAX_PS_CONSTS_F))
return WINED3DERR_INVALIDCALL;
wined3d_mutex_lock();
src = device->stateblock_state->ps_consts_f;
memcpy(constants, &src[start_idx], count * sizeof(*src));
hr = wined3d_stateblock_get_ps_consts_f(device->state, start_idx, count, (struct wined3d_vec4 *)constants);
wined3d_mutex_unlock();
return D3D_OK;
return hr;
}
static HRESULT WINAPI d3d9_device_SetPixelShaderConstantI(IDirect3DDevice9Ex *iface,
......@@ -4063,21 +4038,15 @@ static HRESULT WINAPI d3d9_device_GetPixelShaderConstantI(IDirect3DDevice9Ex *if
UINT start_idx, int *constants, UINT count)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
const struct wined3d_ivec4 *src;
HRESULT hr;
TRACE("iface %p, start_idx %u, constants %p, count %u.\n", iface, start_idx, constants, count);
if (!constants || start_idx >= WINED3D_MAX_CONSTS_I)
return WINED3DERR_INVALIDCALL;
if (count > WINED3D_MAX_CONSTS_I - start_idx)
count = WINED3D_MAX_CONSTS_I - start_idx;
wined3d_mutex_lock();
src = device->stateblock_state->ps_consts_i;
memcpy(constants, &src[start_idx], count * sizeof(*src));
hr = wined3d_stateblock_get_ps_consts_i(device->state, start_idx, count, (struct wined3d_ivec4 *)constants);
wined3d_mutex_unlock();
return D3D_OK;
return hr;
}
static HRESULT WINAPI d3d9_device_SetPixelShaderConstantB(IDirect3DDevice9Ex *iface,
......@@ -4099,19 +4068,15 @@ static HRESULT WINAPI d3d9_device_GetPixelShaderConstantB(IDirect3DDevice9Ex *if
UINT start_idx, BOOL *constants, UINT count)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, start_idx %u, constants %p, count %u.\n", iface, start_idx, constants, count);
if (!constants || start_idx >= WINED3D_MAX_CONSTS_I)
return WINED3DERR_INVALIDCALL;
if (count > WINED3D_MAX_CONSTS_I - start_idx)
count = WINED3D_MAX_CONSTS_I - start_idx;
wined3d_mutex_lock();
memcpy(constants, &device->stateblock_state->ps_consts_b[start_idx], count * sizeof(*constants));
hr = wined3d_stateblock_get_ps_consts_b(device->state, start_idx, count, constants);
wined3d_mutex_unlock();
return D3D_OK;
return hr;
}
static HRESULT WINAPI d3d9_device_DrawRectPatch(IDirect3DDevice9Ex *iface, UINT handle,
......
......@@ -1245,6 +1245,50 @@ HRESULT CDECL wined3d_stateblock_set_vs_consts_b(struct wined3d_stateblock *stat
return WINED3D_OK;
}
HRESULT CDECL wined3d_stateblock_get_vs_consts_f(struct wined3d_stateblock *stateblock,
unsigned int start_idx, unsigned int count, struct wined3d_vec4 *constants)
{
const struct wined3d_d3d_info *d3d_info = &stateblock->device->adapter->d3d_info;
TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n", stateblock, start_idx, count, constants);
if (!constants || !wined3d_bound_range(start_idx, count, d3d_info->limits.vs_uniform_count))
return WINED3DERR_INVALIDCALL;
memcpy(constants, &stateblock->stateblock_state.vs_consts_f[start_idx], count * sizeof(*constants));
return WINED3D_OK;
}
HRESULT CDECL wined3d_stateblock_get_vs_consts_i(struct wined3d_stateblock *stateblock,
unsigned int start_idx, unsigned int count, struct wined3d_ivec4 *constants)
{
TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n", stateblock, start_idx, count, constants);
if (!constants || start_idx >= WINED3D_MAX_CONSTS_I)
return WINED3DERR_INVALIDCALL;
if (count > WINED3D_MAX_CONSTS_I - start_idx)
count = WINED3D_MAX_CONSTS_I - start_idx;
memcpy(constants, &stateblock->stateblock_state.vs_consts_i[start_idx], count * sizeof(*constants));
return WINED3D_OK;
}
HRESULT CDECL wined3d_stateblock_get_vs_consts_b(struct wined3d_stateblock *stateblock,
unsigned int start_idx, unsigned int count, BOOL *constants)
{
TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n", stateblock, start_idx, count, constants);
if (!constants || start_idx >= WINED3D_MAX_CONSTS_B)
return WINED3DERR_INVALIDCALL;
if (count > WINED3D_MAX_CONSTS_B - start_idx)
count = WINED3D_MAX_CONSTS_B - start_idx;
memcpy(constants, &stateblock->stateblock_state.vs_consts_b[start_idx], count * sizeof(*constants));
return WINED3D_OK;
}
void CDECL wined3d_stateblock_set_pixel_shader(struct wined3d_stateblock *stateblock, struct wined3d_shader *shader)
{
TRACE("stateblock %p, shader %p.\n", stateblock, shader);
......@@ -1313,6 +1357,48 @@ HRESULT CDECL wined3d_stateblock_set_ps_consts_b(struct wined3d_stateblock *stat
return WINED3D_OK;
}
HRESULT CDECL wined3d_stateblock_get_ps_consts_f(struct wined3d_stateblock *stateblock,
unsigned int start_idx, unsigned int count, struct wined3d_vec4 *constants)
{
TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n", stateblock, start_idx, count, constants);
if (!constants || !wined3d_bound_range(start_idx, count, WINED3D_MAX_PS_CONSTS_F))
return WINED3DERR_INVALIDCALL;
memcpy(constants, &stateblock->stateblock_state.ps_consts_f[start_idx], count * sizeof(*constants));
return WINED3D_OK;
}
HRESULT CDECL wined3d_stateblock_get_ps_consts_i(struct wined3d_stateblock *stateblock,
unsigned int start_idx, unsigned int count, struct wined3d_ivec4 *constants)
{
TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n", stateblock, start_idx, count, constants);
if (!constants || start_idx >= WINED3D_MAX_CONSTS_I)
return WINED3DERR_INVALIDCALL;
if (count > WINED3D_MAX_CONSTS_I - start_idx)
count = WINED3D_MAX_CONSTS_I - start_idx;
memcpy(constants, &stateblock->stateblock_state.ps_consts_i[start_idx], count * sizeof(*constants));
return WINED3D_OK;
}
HRESULT CDECL wined3d_stateblock_get_ps_consts_b(struct wined3d_stateblock *stateblock,
unsigned int start_idx, unsigned int count, BOOL *constants)
{
TRACE("stateblock %p, start_idx %u, count %u, constants %p.\n", stateblock, start_idx, count, constants);
if (!constants || start_idx >= WINED3D_MAX_CONSTS_B)
return WINED3DERR_INVALIDCALL;
if (count > WINED3D_MAX_CONSTS_B - start_idx)
count = WINED3D_MAX_CONSTS_B - start_idx;
memcpy(constants, &stateblock->stateblock_state.ps_consts_b[start_idx], count * sizeof(*constants));
return WINED3D_OK;
}
void CDECL wined3d_stateblock_set_vertex_declaration(struct wined3d_stateblock *stateblock,
struct wined3d_vertex_declaration *declaration)
{
......
......@@ -231,7 +231,13 @@
@ cdecl wined3d_stateblock_create(ptr ptr long ptr)
@ cdecl wined3d_stateblock_decref(ptr)
@ cdecl wined3d_stateblock_get_light(ptr long ptr ptr)
@ cdecl wined3d_stateblock_get_ps_consts_b(ptr long long ptr)
@ cdecl wined3d_stateblock_get_ps_consts_f(ptr long long ptr)
@ cdecl wined3d_stateblock_get_ps_consts_i(ptr long long ptr)
@ cdecl wined3d_stateblock_get_state(ptr)
@ cdecl wined3d_stateblock_get_vs_consts_b(ptr long long ptr)
@ cdecl wined3d_stateblock_get_vs_consts_f(ptr long long ptr)
@ cdecl wined3d_stateblock_get_vs_consts_i(ptr long long ptr)
@ cdecl wined3d_stateblock_incref(ptr)
@ cdecl wined3d_stateblock_init_contained_states(ptr)
@ cdecl wined3d_stateblock_multiply_transform(ptr long ptr)
......
......@@ -2753,7 +2753,19 @@ HRESULT __cdecl wined3d_stateblock_create(struct wined3d_device *device, const s
ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock);
HRESULT __cdecl wined3d_stateblock_get_light(const struct wined3d_stateblock *stateblock,
UINT light_idx, struct wined3d_light *light, BOOL *enabled);
HRESULT __cdecl wined3d_stateblock_get_ps_consts_b(struct wined3d_stateblock *stateblock,
unsigned int start_idx, unsigned int count, 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);
const struct wined3d_stateblock_state * __cdecl wined3d_stateblock_get_state(const struct wined3d_stateblock *stateblock);
HRESULT __cdecl wined3d_stateblock_get_vs_consts_b(struct wined3d_stateblock *stateblock,
unsigned int start_idx, unsigned int count, 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);
ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock);
void __cdecl wined3d_stateblock_init_contained_states(struct wined3d_stateblock *stateblock);
void __cdecl wined3d_stateblock_multiply_transform(struct wined3d_stateblock *stateblock,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment