d3d10core: Implement d3d10_device_VSSetShaderResources().

This commit is contained in:
Henri Verbeet 2014-09-16 10:44:16 +02:00 committed by Alexandre Julliard
parent e01d207699
commit 1e434b52d0
8 changed files with 125 additions and 34 deletions

View File

@ -165,6 +165,8 @@ struct d3d10_shader_resource_view
HRESULT d3d10_shader_resource_view_init(struct d3d10_shader_resource_view *view, struct d3d10_device *device, HRESULT d3d10_shader_resource_view_init(struct d3d10_shader_resource_view *view, struct d3d10_device *device,
ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc) DECLSPEC_HIDDEN; ID3D10Resource *resource, const D3D10_SHADER_RESOURCE_VIEW_DESC *desc) DECLSPEC_HIDDEN;
struct d3d10_shader_resource_view *unsafe_impl_from_ID3D10ShaderResourceView(
ID3D10ShaderResourceView *iface) DECLSPEC_HIDDEN;
/* ID3D10InputLayout */ /* ID3D10InputLayout */
struct d3d10_input_layout struct d3d10_input_layout

View File

@ -339,8 +339,19 @@ static void STDMETHODCALLTYPE d3d10_device_IASetPrimitiveTopology(ID3D10Device1
static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device1 *iface, static void STDMETHODCALLTYPE d3d10_device_VSSetShaderResources(ID3D10Device1 *iface,
UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views) UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views)
{ {
FIXME("iface %p, start_slot %u, view_count %u, views %p stub!\n", struct d3d10_device *device = impl_from_ID3D10Device(iface);
unsigned int i;
TRACE("iface %p, start_slot %u, view_count %u, views %p.\n",
iface, start_slot, view_count, views); iface, start_slot, view_count, views);
for (i = 0; i < view_count; ++i)
{
struct d3d10_shader_resource_view *view = unsafe_impl_from_ID3D10ShaderResourceView(views[i]);
wined3d_device_set_vs_resource_view(device->wined3d_device, start_slot + i,
view ? view->wined3d_view : NULL);
}
} }
static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device1 *iface, static void STDMETHODCALLTYPE d3d10_device_VSSetSamplers(ID3D10Device1 *iface,

View File

@ -1015,3 +1015,11 @@ HRESULT d3d10_shader_resource_view_init(struct d3d10_shader_resource_view *view,
return S_OK; return S_OK;
} }
struct d3d10_shader_resource_view *unsafe_impl_from_ID3D10ShaderResourceView(ID3D10ShaderResourceView *iface)
{
if (!iface)
return NULL;
assert(iface->lpVtbl == &d3d10_shader_resource_view_vtbl);
return CONTAINING_RECORD(iface, struct d3d10_shader_resource_view, ID3D10ShaderResourceView_iface);
}

View File

@ -40,6 +40,7 @@ enum wined3d_cs_op
WINED3D_CS_OP_SET_INDEX_BUFFER, WINED3D_CS_OP_SET_INDEX_BUFFER,
WINED3D_CS_OP_SET_CONSTANT_BUFFER, WINED3D_CS_OP_SET_CONSTANT_BUFFER,
WINED3D_CS_OP_SET_TEXTURE, WINED3D_CS_OP_SET_TEXTURE,
WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW,
WINED3D_CS_OP_SET_SAMPLER, WINED3D_CS_OP_SET_SAMPLER,
WINED3D_CS_OP_SET_SHADER, WINED3D_CS_OP_SET_SHADER,
WINED3D_CS_OP_SET_RENDER_STATE, WINED3D_CS_OP_SET_RENDER_STATE,
@ -161,6 +162,14 @@ struct wined3d_cs_set_texture
struct wined3d_texture *texture; struct wined3d_texture *texture;
}; };
struct wined3d_cs_set_shader_resource_view
{
enum wined3d_cs_op opcode;
enum wined3d_shader_type type;
UINT view_idx;
struct wined3d_shader_resource_view *view;
};
struct wined3d_cs_set_sampler struct wined3d_cs_set_sampler
{ {
enum wined3d_cs_op opcode; enum wined3d_cs_op opcode;
@ -657,6 +666,27 @@ void wined3d_cs_emit_set_texture(struct wined3d_cs *cs, UINT stage, struct wined
cs->ops->submit(cs); cs->ops->submit(cs);
} }
static void wined3d_cs_exec_set_shader_resource_view(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_cs_set_shader_resource_view *op = data;
cs->state.shader_resource_view[op->type][op->view_idx] = op->view;
}
void wined3d_cs_emit_set_shader_resource_view(struct wined3d_cs *cs, enum wined3d_shader_type type,
UINT view_idx, struct wined3d_shader_resource_view *view)
{
struct wined3d_cs_set_shader_resource_view *op;
op = cs->ops->require_space(cs, sizeof(*op));
op->opcode = WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW;
op->type = type;
op->view_idx = view_idx;
op->view = view;
cs->ops->submit(cs);
}
static void wined3d_cs_exec_set_sampler(struct wined3d_cs *cs, const void *data) static void wined3d_cs_exec_set_sampler(struct wined3d_cs *cs, const void *data)
{ {
const struct wined3d_cs_set_sampler *op = data; const struct wined3d_cs_set_sampler *op = data;
@ -847,29 +877,30 @@ void wined3d_cs_emit_reset_state(struct wined3d_cs *cs)
static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) = static void (* const wined3d_cs_op_handlers[])(struct wined3d_cs *cs, const void *data) =
{ {
/* WINED3D_CS_OP_PRESENT */ wined3d_cs_exec_present, /* WINED3D_CS_OP_PRESENT */ wined3d_cs_exec_present,
/* WINED3D_CS_OP_CLEAR */ wined3d_cs_exec_clear, /* WINED3D_CS_OP_CLEAR */ wined3d_cs_exec_clear,
/* WINED3D_CS_OP_DRAW */ wined3d_cs_exec_draw, /* WINED3D_CS_OP_DRAW */ wined3d_cs_exec_draw,
/* WINED3D_CS_OP_SET_VIEWPORT */ wined3d_cs_exec_set_viewport, /* WINED3D_CS_OP_SET_VIEWPORT */ wined3d_cs_exec_set_viewport,
/* WINED3D_CS_OP_SET_SCISSOR_RECT */ wined3d_cs_exec_set_scissor_rect, /* WINED3D_CS_OP_SET_SCISSOR_RECT */ wined3d_cs_exec_set_scissor_rect,
/* WINED3D_CS_OP_SET_RENDERTARGET_VIEW */ wined3d_cs_exec_set_rendertarget_view, /* WINED3D_CS_OP_SET_RENDERTARGET_VIEW */ wined3d_cs_exec_set_rendertarget_view,
/* WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW */ wined3d_cs_exec_set_depth_stencil_view, /* WINED3D_CS_OP_SET_DEPTH_STENCIL_VIEW */ wined3d_cs_exec_set_depth_stencil_view,
/* WINED3D_CS_OP_SET_VERTEX_DECLARATION */ wined3d_cs_exec_set_vertex_declaration, /* WINED3D_CS_OP_SET_VERTEX_DECLARATION */ wined3d_cs_exec_set_vertex_declaration,
/* WINED3D_CS_OP_SET_STREAM_SOURCE */ wined3d_cs_exec_set_stream_source, /* WINED3D_CS_OP_SET_STREAM_SOURCE */ wined3d_cs_exec_set_stream_source,
/* WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ */ wined3d_cs_exec_set_stream_source_freq, /* WINED3D_CS_OP_SET_STREAM_SOURCE_FREQ */ wined3d_cs_exec_set_stream_source_freq,
/* WINED3D_CS_OP_SET_STREAM_OUTPUT */ wined3d_cs_exec_set_stream_output, /* WINED3D_CS_OP_SET_STREAM_OUTPUT */ wined3d_cs_exec_set_stream_output,
/* WINED3D_CS_OP_SET_INDEX_BUFFER */ wined3d_cs_exec_set_index_buffer, /* WINED3D_CS_OP_SET_INDEX_BUFFER */ wined3d_cs_exec_set_index_buffer,
/* WINED3D_CS_OP_SET_CONSTANT_BUFFER */ wined3d_cs_exec_set_constant_buffer, /* WINED3D_CS_OP_SET_CONSTANT_BUFFER */ wined3d_cs_exec_set_constant_buffer,
/* WINED3D_CS_OP_SET_TEXTURE */ wined3d_cs_exec_set_texture, /* WINED3D_CS_OP_SET_TEXTURE */ wined3d_cs_exec_set_texture,
/* WINED3D_CS_OP_SET_SAMPLER */ wined3d_cs_exec_set_sampler, /* WINED3D_CS_OP_SET_SHADER_RESOURCE_VIEW */ wined3d_cs_exec_set_shader_resource_view,
/* WINED3D_CS_OP_SET_SHADER */ wined3d_cs_exec_set_shader, /* WINED3D_CS_OP_SET_SAMPLER */ wined3d_cs_exec_set_sampler,
/* WINED3D_CS_OP_SET_RENDER_STATE */ wined3d_cs_exec_set_render_state, /* WINED3D_CS_OP_SET_SHADER */ wined3d_cs_exec_set_shader,
/* WINED3D_CS_OP_SET_TEXTURE_STATE */ wined3d_cs_exec_set_texture_state, /* WINED3D_CS_OP_SET_RENDER_STATE */ wined3d_cs_exec_set_render_state,
/* WINED3D_CS_OP_SET_SAMPLER_STATE */ wined3d_cs_exec_set_sampler_state, /* WINED3D_CS_OP_SET_TEXTURE_STATE */ wined3d_cs_exec_set_texture_state,
/* WINED3D_CS_OP_SET_TRANSFORM */ wined3d_cs_exec_set_transform, /* WINED3D_CS_OP_SET_SAMPLER_STATE */ wined3d_cs_exec_set_sampler_state,
/* WINED3D_CS_OP_SET_CLIP_PLANE */ wined3d_cs_exec_set_clip_plane, /* WINED3D_CS_OP_SET_TRANSFORM */ wined3d_cs_exec_set_transform,
/* WINED3D_CS_OP_SET_MATERIAL */ wined3d_cs_exec_set_material, /* WINED3D_CS_OP_SET_CLIP_PLANE */ wined3d_cs_exec_set_clip_plane,
/* WINED3D_CS_OP_RESET_STATE */ wined3d_cs_exec_reset_state, /* WINED3D_CS_OP_SET_MATERIAL */ wined3d_cs_exec_set_material,
/* WINED3D_CS_OP_RESET_STATE */ wined3d_cs_exec_reset_state,
}; };
static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size) static void *wined3d_cs_st_require_space(struct wined3d_cs *cs, size_t size)

View File

@ -2140,6 +2140,38 @@ struct wined3d_buffer * CDECL wined3d_device_get_vs_cb(const struct wined3d_devi
return device->state.cb[WINED3D_SHADER_TYPE_VERTEX][idx]; return device->state.cb[WINED3D_SHADER_TYPE_VERTEX][idx];
} }
static void wined3d_device_set_shader_resource_view(struct wined3d_device *device,
enum wined3d_shader_type type, UINT idx, struct wined3d_shader_resource_view *view)
{
struct wined3d_shader_resource_view *prev;
if (idx >= MAX_SHADER_RESOURCE_VIEWS)
{
WARN("Invalid view index %u.\n", idx);
return;
}
prev = device->update_state->shader_resource_view[type][idx];
if (view == prev)
return;
if (view)
wined3d_shader_resource_view_incref(view);
device->update_state->shader_resource_view[type][idx] = view;
if (!device->recording)
wined3d_cs_emit_set_shader_resource_view(device->cs, type, idx, view);
if (prev)
wined3d_shader_resource_view_decref(prev);
}
void CDECL wined3d_device_set_vs_resource_view(struct wined3d_device *device,
UINT idx, struct wined3d_shader_resource_view *view)
{
TRACE("device %p, idx %u, view %p.\n", device, idx, view);
wined3d_device_set_shader_resource_view(device, WINED3D_SHADER_TYPE_VERTEX, idx, view);
}
static void wined3d_device_set_sampler(struct wined3d_device *device, static void wined3d_device_set_sampler(struct wined3d_device *device,
enum wined3d_shader_type type, UINT idx, struct wined3d_sampler *sampler) enum wined3d_shader_type type, UINT idx, struct wined3d_sampler *sampler)
{ {

View File

@ -146,6 +146,7 @@
@ cdecl wined3d_device_set_vs_consts_b(ptr long ptr long) @ cdecl wined3d_device_set_vs_consts_b(ptr long ptr long)
@ cdecl wined3d_device_set_vs_consts_f(ptr long ptr long) @ cdecl wined3d_device_set_vs_consts_f(ptr long ptr long)
@ cdecl wined3d_device_set_vs_consts_i(ptr long ptr long) @ cdecl wined3d_device_set_vs_consts_i(ptr long ptr long)
@ cdecl wined3d_device_set_vs_resource_view(ptr long ptr)
@ cdecl wined3d_device_set_vs_sampler(ptr long ptr) @ cdecl wined3d_device_set_vs_sampler(ptr long ptr)
@ cdecl wined3d_device_setup_fullscreen_window(ptr ptr long long) @ cdecl wined3d_device_setup_fullscreen_window(ptr ptr long long)
@ cdecl wined3d_device_show_cursor(ptr long) @ cdecl wined3d_device_show_cursor(ptr long)

View File

@ -156,16 +156,17 @@ void *wined3d_rb_realloc(void *ptr, size_t size) DECLSPEC_HIDDEN;
void wined3d_rb_free(void *ptr) DECLSPEC_HIDDEN; void wined3d_rb_free(void *ptr) DECLSPEC_HIDDEN;
/* Device caps */ /* Device caps */
#define MAX_STREAM_OUT 4 #define MAX_STREAM_OUT 4
#define MAX_STREAMS 16 #define MAX_STREAMS 16
#define MAX_TEXTURES 8 #define MAX_TEXTURES 8
#define MAX_FRAGMENT_SAMPLERS 16 #define MAX_FRAGMENT_SAMPLERS 16
#define MAX_VERTEX_SAMPLERS 4 #define MAX_VERTEX_SAMPLERS 4
#define MAX_COMBINED_SAMPLERS (MAX_FRAGMENT_SAMPLERS + MAX_VERTEX_SAMPLERS) #define MAX_COMBINED_SAMPLERS (MAX_FRAGMENT_SAMPLERS + MAX_VERTEX_SAMPLERS)
#define MAX_ACTIVE_LIGHTS 8 #define MAX_ACTIVE_LIGHTS 8
#define MAX_CLIPPLANES WINED3DMAXUSERCLIPPLANES #define MAX_CLIPPLANES WINED3DMAXUSERCLIPPLANES
#define MAX_CONSTANT_BUFFERS 15 #define MAX_CONSTANT_BUFFERS 15
#define MAX_SAMPLER_OBJECTS 16 #define MAX_SAMPLER_OBJECTS 16
#define MAX_SHADER_RESOURCE_VIEWS 128
struct min_lookup struct min_lookup
{ {
@ -1865,6 +1866,7 @@ struct wined3d_state
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 *cb[WINED3D_SHADER_TYPE_COUNT][MAX_CONSTANT_BUFFERS];
struct wined3d_sampler *sampler[WINED3D_SHADER_TYPE_COUNT][MAX_SAMPLER_OBJECTS]; struct wined3d_sampler *sampler[WINED3D_SHADER_TYPE_COUNT][MAX_SAMPLER_OBJECTS];
struct wined3d_shader_resource_view *shader_resource_view[WINED3D_SHADER_TYPE_COUNT][MAX_SHADER_RESOURCE_VIEWS];
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];
@ -2510,6 +2512,8 @@ void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs,
enum wined3d_render_state state, DWORD value) DECLSPEC_HIDDEN; enum wined3d_render_state state, DWORD value) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_rendertarget_view(struct wined3d_cs *cs, unsigned int view_idx, void wined3d_cs_emit_set_rendertarget_view(struct wined3d_cs *cs, unsigned int view_idx,
struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN; struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_shader_resource_view(struct wined3d_cs *cs, enum wined3d_shader_type type,
UINT view_idx, struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_sampler(struct wined3d_cs *cs, enum wined3d_shader_type type, void wined3d_cs_emit_set_sampler(struct wined3d_cs *cs, enum wined3d_shader_type type,
UINT sampler_idx, struct wined3d_sampler *sampler) DECLSPEC_HIDDEN; UINT sampler_idx, struct wined3d_sampler *sampler) DECLSPEC_HIDDEN;
void wined3d_cs_emit_set_sampler_state(struct wined3d_cs *cs, UINT sampler_idx, void wined3d_cs_emit_set_sampler_state(struct wined3d_cs *cs, UINT sampler_idx,

View File

@ -2265,6 +2265,8 @@ HRESULT __cdecl wined3d_device_set_vs_consts_f(struct wined3d_device *device,
UINT start_register, const float *constants, UINT vector4f_count); UINT start_register, const float *constants, UINT vector4f_count);
HRESULT __cdecl wined3d_device_set_vs_consts_i(struct wined3d_device *device, HRESULT __cdecl wined3d_device_set_vs_consts_i(struct wined3d_device *device,
UINT start_register, const int *constants, UINT vector4i_count); UINT start_register, const int *constants, UINT vector4i_count);
void __cdecl wined3d_device_set_vs_resource_view(struct wined3d_device *device,
UINT idx, struct wined3d_shader_resource_view *view);
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);
void __cdecl wined3d_device_setup_fullscreen_window(struct wined3d_device *device, HWND window, UINT w, UINT h); void __cdecl wined3d_device_setup_fullscreen_window(struct wined3d_device *device, HWND window, UINT w, UINT h);
BOOL __cdecl wined3d_device_show_cursor(struct wined3d_device *device, BOOL show); BOOL __cdecl wined3d_device_show_cursor(struct wined3d_device *device, BOOL show);