Commit 392a65fe authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Unify sampler binding points.

parent 3caefc83
......@@ -2144,20 +2144,19 @@ struct wined3d_buffer * CDECL wined3d_device_get_vs_cb(const struct wined3d_devi
return device->state.cb[WINED3D_SHADER_TYPE_VERTEX][idx];
}
void CDECL wined3d_device_set_vs_sampler(struct wined3d_device *device, UINT idx, struct wined3d_sampler *sampler)
static void wined3d_device_set_sampler(struct wined3d_device *device,
enum wined3d_shader_type type, UINT idx, struct wined3d_sampler *sampler)
{
struct wined3d_sampler *prev;
TRACE("device %p, idx %u, sampler %p.\n", device, idx, sampler);
if (idx >= MAX_SAMPLER_OBJECTS)
{
WARN("Invalid sampler index %u.\n", idx);
return;
}
prev = device->update_state->vs_sampler[idx];
device->update_state->vs_sampler[idx] = sampler;
prev = device->update_state->sampler[type][idx];
device->update_state->sampler[type][idx] = sampler;
if (sampler)
wined3d_sampler_incref(sampler);
......@@ -2165,6 +2164,13 @@ void CDECL wined3d_device_set_vs_sampler(struct wined3d_device *device, UINT idx
wined3d_sampler_decref(prev);
}
void CDECL wined3d_device_set_vs_sampler(struct wined3d_device *device, UINT idx, struct wined3d_sampler *sampler)
{
TRACE("device %p, idx %u, sampler %p.\n", device, idx, sampler);
wined3d_device_set_sampler(device, WINED3D_SHADER_TYPE_VERTEX, idx, sampler);
}
struct wined3d_sampler * CDECL wined3d_device_get_vs_sampler(const struct wined3d_device *device, UINT idx)
{
TRACE("device %p, idx %u.\n", device, idx);
......@@ -2175,7 +2181,7 @@ struct wined3d_sampler * CDECL wined3d_device_get_vs_sampler(const struct wined3
return NULL;
}
return device->state.vs_sampler[idx];
return device->state.sampler[WINED3D_SHADER_TYPE_VERTEX][idx];
}
static void device_invalidate_shader_constants(const struct wined3d_device *device, DWORD mask)
......@@ -2382,23 +2388,9 @@ struct wined3d_buffer * CDECL wined3d_device_get_ps_cb(const struct wined3d_devi
void CDECL wined3d_device_set_ps_sampler(struct wined3d_device *device, UINT idx, struct wined3d_sampler *sampler)
{
struct wined3d_sampler *prev;
TRACE("device %p, idx %u, sampler %p.\n", device, idx, sampler);
if (idx >= MAX_SAMPLER_OBJECTS)
{
WARN("Invalid sampler index %u.\n", idx);
return;
}
prev = device->update_state->ps_sampler[idx];
device->update_state->ps_sampler[idx] = sampler;
if (sampler)
wined3d_sampler_incref(sampler);
if (prev)
wined3d_sampler_decref(prev);
wined3d_device_set_sampler(device, WINED3D_SHADER_TYPE_PIXEL, idx, sampler);
}
struct wined3d_sampler * CDECL wined3d_device_get_ps_sampler(const struct wined3d_device *device, UINT idx)
......@@ -2411,7 +2403,7 @@ struct wined3d_sampler * CDECL wined3d_device_get_ps_sampler(const struct wined3
return NULL;
}
return device->state.ps_sampler[idx];
return device->state.sampler[WINED3D_SHADER_TYPE_PIXEL][idx];
}
HRESULT CDECL wined3d_device_set_ps_consts_b(struct wined3d_device *device,
......@@ -2603,23 +2595,9 @@ struct wined3d_buffer * CDECL wined3d_device_get_gs_cb(const struct wined3d_devi
void CDECL wined3d_device_set_gs_sampler(struct wined3d_device *device, UINT idx, struct wined3d_sampler *sampler)
{
struct wined3d_sampler *prev;
TRACE("device %p, idx %u, sampler %p.\n", device, idx, sampler);
if (idx >= MAX_SAMPLER_OBJECTS)
{
WARN("Invalid sampler index %u.\n", idx);
return;
}
prev = device->update_state->gs_sampler[idx];
device->update_state->gs_sampler[idx] = sampler;
if (sampler)
wined3d_sampler_incref(sampler);
if (prev)
wined3d_sampler_decref(prev);
wined3d_device_set_sampler(device, WINED3D_SHADER_TYPE_GEOMETRY, idx, sampler);
}
struct wined3d_sampler * CDECL wined3d_device_get_gs_sampler(const struct wined3d_device *device, UINT idx)
......@@ -2632,7 +2610,7 @@ struct wined3d_sampler * CDECL wined3d_device_get_gs_sampler(const struct wined3
return NULL;
}
return device->state.gs_sampler[idx];
return device->state.sampler[WINED3D_SHADER_TYPE_GEOMETRY][idx];
}
/* Context activation is done by the caller. */
......
......@@ -520,32 +520,14 @@ void state_unbind_resources(struct wined3d_state *state)
wined3d_buffer_decref(buffer);
}
}
}
for (i = 0; i < MAX_SAMPLER_OBJECTS; ++i)
{
if ((sampler = state->vs_sampler[i]))
{
state->vs_sampler[i] = NULL;
wined3d_sampler_decref(sampler);
}
}
for (i = 0; i < MAX_SAMPLER_OBJECTS; ++i)
{
if ((sampler = state->gs_sampler[i]))
{
state->gs_sampler[i] = NULL;
wined3d_sampler_decref(sampler);
}
}
for (i = 0; i < MAX_SAMPLER_OBJECTS; ++i)
{
if ((sampler = state->ps_sampler[i]))
for (j = 0; j < MAX_SAMPLER_OBJECTS; ++j)
{
state->ps_sampler[i] = NULL;
wined3d_sampler_decref(sampler);
if ((sampler = state->sampler[i][j]))
{
state->sampler[i][j] = NULL;
wined3d_sampler_decref(sampler);
}
}
}
}
......
......@@ -1819,15 +1819,12 @@ struct wined3d_state
struct wined3d_shader *shader[WINED3D_SHADER_TYPE_COUNT];
struct wined3d_buffer *cb[WINED3D_SHADER_TYPE_COUNT][MAX_CONSTANT_BUFFERS];
struct wined3d_sampler *sampler[WINED3D_SHADER_TYPE_COUNT][MAX_SAMPLER_OBJECTS];
struct wined3d_sampler *vs_sampler[MAX_SAMPLER_OBJECTS];
BOOL vs_consts_b[MAX_CONST_B];
INT vs_consts_i[MAX_CONST_I * 4];
float *vs_consts_f;
struct wined3d_sampler *gs_sampler[MAX_SAMPLER_OBJECTS];
struct wined3d_sampler *ps_sampler[MAX_SAMPLER_OBJECTS];
BOOL ps_consts_b[MAX_CONST_B];
INT ps_consts_i[MAX_CONST_I * 4];
float *ps_consts_f;
......
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