Commit 3caefc83 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Unify constant buffer binding points.

parent c228ffba
...@@ -2086,20 +2086,19 @@ struct wined3d_shader * CDECL wined3d_device_get_vertex_shader(const struct wine ...@@ -2086,20 +2086,19 @@ struct wined3d_shader * CDECL wined3d_device_get_vertex_shader(const struct wine
return device->state.shader[WINED3D_SHADER_TYPE_VERTEX]; return device->state.shader[WINED3D_SHADER_TYPE_VERTEX];
} }
void CDECL wined3d_device_set_vs_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer) static void wined3d_device_set_constant_buffer(struct wined3d_device *device,
enum wined3d_shader_type type, UINT idx, struct wined3d_buffer *buffer)
{ {
struct wined3d_buffer *prev; struct wined3d_buffer *prev;
TRACE("device %p, idx %u, buffer %p.\n", device, idx, buffer);
if (idx >= MAX_CONSTANT_BUFFERS) if (idx >= MAX_CONSTANT_BUFFERS)
{ {
WARN("Invalid constant buffer index %u.\n", idx); WARN("Invalid constant buffer index %u.\n", idx);
return; return;
} }
prev = device->update_state->vs_cb[idx]; prev = device->update_state->cb[type][idx];
device->update_state->vs_cb[idx] = buffer; device->update_state->cb[type][idx] = buffer;
if (device->recording) if (device->recording)
{ {
...@@ -2125,6 +2124,13 @@ void CDECL wined3d_device_set_vs_cb(struct wined3d_device *device, UINT idx, str ...@@ -2125,6 +2124,13 @@ void CDECL wined3d_device_set_vs_cb(struct wined3d_device *device, UINT idx, str
} }
} }
void CDECL wined3d_device_set_vs_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer)
{
TRACE("device %p, idx %u, buffer %p.\n", device, idx, buffer);
wined3d_device_set_constant_buffer(device, WINED3D_SHADER_TYPE_VERTEX, idx, buffer);
}
struct wined3d_buffer * CDECL wined3d_device_get_vs_cb(const struct wined3d_device *device, UINT idx) struct wined3d_buffer * CDECL wined3d_device_get_vs_cb(const struct wined3d_device *device, UINT idx)
{ {
TRACE("device %p, idx %u.\n", device, idx); TRACE("device %p, idx %u.\n", device, idx);
...@@ -2135,7 +2141,7 @@ struct wined3d_buffer * CDECL wined3d_device_get_vs_cb(const struct wined3d_devi ...@@ -2135,7 +2141,7 @@ struct wined3d_buffer * CDECL wined3d_device_get_vs_cb(const struct wined3d_devi
return NULL; return NULL;
} }
return device->state.vs_cb[idx]; 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) void CDECL wined3d_device_set_vs_sampler(struct wined3d_device *device, UINT idx, struct wined3d_sampler *sampler)
...@@ -2356,41 +2362,9 @@ struct wined3d_shader * CDECL wined3d_device_get_pixel_shader(const struct wined ...@@ -2356,41 +2362,9 @@ struct wined3d_shader * CDECL wined3d_device_get_pixel_shader(const struct wined
void CDECL wined3d_device_set_ps_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer) void CDECL wined3d_device_set_ps_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer)
{ {
struct wined3d_buffer *prev;
TRACE("device %p, idx %u, buffer %p.\n", device, idx, buffer); TRACE("device %p, idx %u, buffer %p.\n", device, idx, buffer);
if (idx >= MAX_CONSTANT_BUFFERS) wined3d_device_set_constant_buffer(device, WINED3D_SHADER_TYPE_PIXEL, idx, buffer);
{
WARN("Invalid constant buffer index %u.\n", idx);
return;
}
prev = device->update_state->ps_cb[idx];
device->update_state->ps_cb[idx] = buffer;
if (device->recording)
{
if (buffer)
wined3d_buffer_incref(buffer);
if (prev)
wined3d_buffer_decref(prev);
return;
}
if (prev != buffer)
{
if (buffer)
{
InterlockedIncrement(&buffer->resource.bind_count);
wined3d_buffer_incref(buffer);
}
if (prev)
{
InterlockedDecrement(&prev->resource.bind_count);
wined3d_buffer_decref(prev);
}
}
} }
struct wined3d_buffer * CDECL wined3d_device_get_ps_cb(const struct wined3d_device *device, UINT idx) struct wined3d_buffer * CDECL wined3d_device_get_ps_cb(const struct wined3d_device *device, UINT idx)
...@@ -2403,7 +2377,7 @@ struct wined3d_buffer * CDECL wined3d_device_get_ps_cb(const struct wined3d_devi ...@@ -2403,7 +2377,7 @@ struct wined3d_buffer * CDECL wined3d_device_get_ps_cb(const struct wined3d_devi
return NULL; return NULL;
} }
return device->state.ps_cb[idx]; return device->state.cb[WINED3D_SHADER_TYPE_PIXEL][idx];
} }
void CDECL wined3d_device_set_ps_sampler(struct wined3d_device *device, UINT idx, struct wined3d_sampler *sampler) void CDECL wined3d_device_set_ps_sampler(struct wined3d_device *device, UINT idx, struct wined3d_sampler *sampler)
...@@ -2609,41 +2583,9 @@ struct wined3d_shader * CDECL wined3d_device_get_geometry_shader(const struct wi ...@@ -2609,41 +2583,9 @@ struct wined3d_shader * CDECL wined3d_device_get_geometry_shader(const struct wi
void CDECL wined3d_device_set_gs_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer) void CDECL wined3d_device_set_gs_cb(struct wined3d_device *device, UINT idx, struct wined3d_buffer *buffer)
{ {
struct wined3d_buffer *prev;
TRACE("device %p, idx %u, buffer %p.\n", device, idx, buffer); TRACE("device %p, idx %u, buffer %p.\n", device, idx, buffer);
if (idx >= MAX_CONSTANT_BUFFERS) wined3d_device_set_constant_buffer(device, WINED3D_SHADER_TYPE_GEOMETRY, idx, buffer);
{
WARN("Invalid constant buffer index %u.\n", idx);
return;
}
prev = device->update_state->gs_cb[idx];
device->update_state->gs_cb[idx] = buffer;
if (device->recording)
{
if (buffer)
wined3d_buffer_incref(buffer);
if (prev)
wined3d_buffer_decref(prev);
return;
}
if (prev != buffer)
{
if (buffer)
{
InterlockedIncrement(&buffer->resource.bind_count);
wined3d_buffer_incref(buffer);
}
if (prev)
{
InterlockedDecrement(&prev->resource.bind_count);
wined3d_buffer_decref(prev);
}
}
} }
struct wined3d_buffer * CDECL wined3d_device_get_gs_cb(const struct wined3d_device *device, UINT idx) struct wined3d_buffer * CDECL wined3d_device_get_gs_cb(const struct wined3d_device *device, UINT idx)
...@@ -2656,7 +2598,7 @@ struct wined3d_buffer * CDECL wined3d_device_get_gs_cb(const struct wined3d_devi ...@@ -2656,7 +2598,7 @@ struct wined3d_buffer * CDECL wined3d_device_get_gs_cb(const struct wined3d_devi
return NULL; return NULL;
} }
return device->state.gs_cb[idx]; return device->state.cb[WINED3D_SHADER_TYPE_GEOMETRY][idx];
} }
void CDECL wined3d_device_set_gs_sampler(struct wined3d_device *device, UINT idx, struct wined3d_sampler *sampler) void CDECL wined3d_device_set_gs_sampler(struct wined3d_device *device, UINT idx, struct wined3d_sampler *sampler)
......
...@@ -463,7 +463,7 @@ void state_unbind_resources(struct wined3d_state *state) ...@@ -463,7 +463,7 @@ void state_unbind_resources(struct wined3d_state *state)
struct wined3d_texture *texture; struct wined3d_texture *texture;
struct wined3d_buffer *buffer; struct wined3d_buffer *buffer;
struct wined3d_shader *shader; struct wined3d_shader *shader;
unsigned int i; unsigned int i, j;
if ((decl = state->vertex_declaration)) if ((decl = state->vertex_declaration))
{ {
...@@ -511,14 +511,14 @@ void state_unbind_resources(struct wined3d_state *state) ...@@ -511,14 +511,14 @@ void state_unbind_resources(struct wined3d_state *state)
state->shader[i] = NULL; state->shader[i] = NULL;
wined3d_shader_decref(shader); wined3d_shader_decref(shader);
} }
}
for (i = 0; i < MAX_CONSTANT_BUFFERS; ++i) for (j = 0; j < MAX_CONSTANT_BUFFERS; ++j)
{
if ((buffer = state->vs_cb[i]))
{ {
state->vs_cb[i] = NULL; if ((buffer = state->cb[i][j]))
wined3d_buffer_decref(buffer); {
state->cb[i][j] = NULL;
wined3d_buffer_decref(buffer);
}
} }
} }
...@@ -531,15 +531,6 @@ void state_unbind_resources(struct wined3d_state *state) ...@@ -531,15 +531,6 @@ void state_unbind_resources(struct wined3d_state *state)
} }
} }
for (i = 0; i < MAX_CONSTANT_BUFFERS; ++i)
{
if ((buffer = state->gs_cb[i]))
{
state->gs_cb[i] = NULL;
wined3d_buffer_decref(buffer);
}
}
for (i = 0; i < MAX_SAMPLER_OBJECTS; ++i) for (i = 0; i < MAX_SAMPLER_OBJECTS; ++i)
{ {
if ((sampler = state->gs_sampler[i])) if ((sampler = state->gs_sampler[i]))
...@@ -557,15 +548,6 @@ void state_unbind_resources(struct wined3d_state *state) ...@@ -557,15 +548,6 @@ void state_unbind_resources(struct wined3d_state *state)
wined3d_sampler_decref(sampler); wined3d_sampler_decref(sampler);
} }
} }
for (i = 0; i < MAX_CONSTANT_BUFFERS; ++i)
{
if ((buffer = state->ps_cb[i]))
{
state->ps_cb[i] = NULL;
wined3d_buffer_decref(buffer);
}
}
} }
void state_cleanup(struct wined3d_state *state) void state_cleanup(struct wined3d_state *state)
......
...@@ -1818,17 +1818,15 @@ struct wined3d_state ...@@ -1818,17 +1818,15 @@ struct wined3d_state
GLenum gl_primitive_type; GLenum gl_primitive_type;
struct wined3d_shader *shader[WINED3D_SHADER_TYPE_COUNT]; struct wined3d_shader *shader[WINED3D_SHADER_TYPE_COUNT];
struct wined3d_buffer *cb[WINED3D_SHADER_TYPE_COUNT][MAX_CONSTANT_BUFFERS];
struct wined3d_buffer *vs_cb[MAX_CONSTANT_BUFFERS];
struct wined3d_sampler *vs_sampler[MAX_SAMPLER_OBJECTS]; struct wined3d_sampler *vs_sampler[MAX_SAMPLER_OBJECTS];
BOOL vs_consts_b[MAX_CONST_B]; BOOL vs_consts_b[MAX_CONST_B];
INT vs_consts_i[MAX_CONST_I * 4]; INT vs_consts_i[MAX_CONST_I * 4];
float *vs_consts_f; float *vs_consts_f;
struct wined3d_buffer *gs_cb[MAX_CONSTANT_BUFFERS];
struct wined3d_sampler *gs_sampler[MAX_SAMPLER_OBJECTS]; struct wined3d_sampler *gs_sampler[MAX_SAMPLER_OBJECTS];
struct wined3d_buffer *ps_cb[MAX_CONSTANT_BUFFERS];
struct wined3d_sampler *ps_sampler[MAX_SAMPLER_OBJECTS]; struct wined3d_sampler *ps_sampler[MAX_SAMPLER_OBJECTS];
BOOL ps_consts_b[MAX_CONST_B]; BOOL ps_consts_b[MAX_CONST_B];
INT ps_consts_i[MAX_CONST_I * 4]; INT ps_consts_i[MAX_CONST_I * 4];
......
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