[PATCH 2/8] wined3d: Unbind textures in context_bind_shader_resources().
Józef Kucia
jkucia at codeweavers.com
Thu Mar 9 03:03:04 CST 2017
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
The WINED3D_LEGACY_TEXTURE_BINDING flag should prevent from generating
the "No resource view bound at index" warnings in D3D9-, allows to
safely unbind resources in context_bind_shader_resources(), and make it
easier easier to add support for more samplers in D3D10+.
---
dlls/d3d11/tests/d3d11.c | 2 +-
dlls/d3d8/directx.c | 2 +-
dlls/d3d9/directx.c | 3 ++-
dlls/ddraw/ddraw_private.h | 2 +-
dlls/wined3d/context.c | 16 +++++++++-------
dlls/wined3d/state.c | 5 ++++-
include/wine/wined3d.h | 1 +
7 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 94a5a8f..53b2e81 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -12329,7 +12329,7 @@ static void test_unbind_shader_resource_view(void)
ID3D11DeviceContext_PSSetShaderResources(context, 1, 1, &srv2);
ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
draw_quad(&test_context);
- todo_wine check_texture_color(test_context.backbuffer, 0x00000000, 1);
+ check_texture_color(test_context.backbuffer, 0x00000000, 1);
ID3D11PixelShader_Release(ps);
ID3D11ShaderResourceView_Release(srv);
diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c
index 107e32d..2033a6d 100644
--- a/dlls/d3d8/directx.c
+++ b/dlls/d3d8/directx.c
@@ -412,7 +412,7 @@ BOOL d3d8_init(struct d3d8 *d3d8)
DWORD flags = WINED3D_LEGACY_DEPTH_BIAS | WINED3D_VIDMEM_ACCOUNTING
| WINED3D_HANDLE_RESTORE | WINED3D_PIXEL_CENTER_INTEGER
| WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR | WINED3D_NO_PRIMITIVE_RESTART
- | WINED3D_LEGACY_CUBEMAP_FILTERING;
+ | WINED3D_LEGACY_CUBEMAP_FILTERING | WINED3D_LEGACY_TEXTURE_BINDING;
d3d8->IDirect3D8_iface.lpVtbl = &d3d8_vtbl;
d3d8->refcount = 1;
diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c
index fe7163f..00570ee 100644
--- a/dlls/d3d9/directx.c
+++ b/dlls/d3d9/directx.c
@@ -580,7 +580,8 @@ BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended)
{
DWORD flags = WINED3D_PRESENT_CONVERSION | WINED3D_HANDLE_RESTORE | WINED3D_PIXEL_CENTER_INTEGER
| WINED3D_SRGB_READ_WRITE_CONTROL | WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR
- | WINED3D_NO_PRIMITIVE_RESTART | WINED3D_LEGACY_CUBEMAP_FILTERING;
+ | WINED3D_NO_PRIMITIVE_RESTART | WINED3D_LEGACY_CUBEMAP_FILTERING
+ | WINED3D_LEGACY_TEXTURE_BINDING;
if (!extended)
flags |= WINED3D_VIDMEM_ACCOUNTING;
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index 48b6c70..5ccf725 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -62,7 +62,7 @@ struct FvfToDecl
#define DDRAW_WINED3D_FLAGS (WINED3D_LEGACY_DEPTH_BIAS | WINED3D_VIDMEM_ACCOUNTING \
| WINED3D_RESTORE_MODE_ON_ACTIVATE | WINED3D_FOCUS_MESSAGES | WINED3D_PIXEL_CENTER_INTEGER \
| WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR | WINED3D_NO_PRIMITIVE_RESTART \
- | WINED3D_LEGACY_CUBEMAP_FILTERING)
+ | WINED3D_LEGACY_CUBEMAP_FILTERING | WINED3D_LEGACY_TEXTURE_BINDING)
enum ddraw_device_state
{
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index a423fac..732c3c6 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -3323,10 +3323,7 @@ static void context_load_shader_resources(struct wined3d_context *context, const
entry = &shader->reg_maps.sampler_map.entries[j];
if (!(view = state->shader_resource_view[i][entry->resource_idx]))
- {
- WARN("No resource view bound at index %u, %u.\n", i, entry->resource_idx);
continue;
- }
if (view->resource->type == WINED3D_RTYPE_BUFFER)
wined3d_buffer_load(buffer_from_resource(view->resource), context, state);
@@ -3343,8 +3340,8 @@ static void context_bind_shader_resources(struct wined3d_context *context,
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_device *device = context->device;
struct wined3d_shader_sampler_map_entry *entry;
+ unsigned int bind_idx, shader_sampler_count, i;
struct wined3d_shader_resource_view *view;
- unsigned int shader_sampler_count, i;
const struct wined3d_shader *shader;
struct wined3d_sampler *sampler;
GLuint sampler_name;
@@ -3361,10 +3358,15 @@ static void context_bind_shader_resources(struct wined3d_context *context,
for (i = 0; i < count; ++i)
{
entry = &shader->reg_maps.sampler_map.entries[i];
+ bind_idx = base_idx + entry->bind_idx;
if (!(view = state->shader_resource_view[shader_type][entry->resource_idx]))
{
WARN("No resource view bound at index %u, %u.\n", shader_type, entry->resource_idx);
+ context_active_texture(context, gl_info, bind_idx);
+ context_bind_texture(context, GL_NONE, 0);
+ GL_EXTCALL(glBindSampler(bind_idx, 0));
+ checkGLcall("unbind shader resource");
continue;
}
@@ -3375,8 +3377,8 @@ static void context_bind_shader_resources(struct wined3d_context *context,
else
sampler_name = device->null_sampler;
- context_active_texture(context, gl_info, base_idx + entry->bind_idx);
- GL_EXTCALL(glBindSampler(base_idx + entry->bind_idx, sampler_name));
+ context_active_texture(context, gl_info, bind_idx);
+ GL_EXTCALL(glBindSampler(bind_idx, sampler_name));
checkGLcall("glBindSampler");
wined3d_shader_resource_view_bind(view, context);
}
@@ -3485,7 +3487,7 @@ static void context_bind_unordered_access_views(struct wined3d_context *context,
if (view->counter_bo)
GL_EXTCALL(glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, i, view->counter_bo));
}
- checkGLcall("Bind unordered access views");
+ checkGLcall("bind unordered access views");
}
/* Context activation is done by the caller. */
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index b73f4a8..461b52e 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -4976,9 +4976,12 @@ static void state_cb_warn(struct wined3d_context *context, const struct wined3d_
static void state_shader_resource_binding(struct wined3d_context *context,
const struct wined3d_state *state, DWORD state_id)
{
+ const struct wined3d_d3d_info *d3d_info = context->d3d_info;
+
TRACE("context %p, state %p, state_id %#x.\n", context, state, state_id);
- context->update_shader_resource_bindings = 1;
+ if (!(d3d_info->wined3d_creation_flags & WINED3D_LEGACY_TEXTURE_BINDING))
+ context->update_shader_resource_bindings = 1;
}
static void state_cs_resource_binding(struct wined3d_context *context,
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index acdb4f3..735574b 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -1280,6 +1280,7 @@ enum wined3d_shader_byte_code_format
#define WINED3D_LEGACY_UNBOUND_RESOURCE_COLOR 0x00000400
#define WINED3D_NO_PRIMITIVE_RESTART 0x00000800
#define WINED3D_LEGACY_CUBEMAP_FILTERING 0x00001000
+#define WINED3D_LEGACY_TEXTURE_BINDING 0x00002000
#define WINED3D_RESZ_CODE 0x7fa05000
--
2.10.2
More information about the wine-patches
mailing list