Commit 3bac75c0 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

wined3d: Add support for NULL sampler.

parent d9f8c853
......@@ -6251,7 +6251,7 @@ static void test_swapchain_flip(void)
color = get_texture_color(offscreen, 120, 240); /* blue, buf 0 */
todo_wine ok(compare_color(color, 0x7fff0000, 1), "Got unexpected color 0x%08x.\n", color);
color = get_texture_color(offscreen, 360, 240); /* red, buf 1 */
todo_wine ok(compare_color(color, 0x7f0000ff, 1), "Got unexpected color 0x%08x.\n", color);
ok(compare_color(color, 0x7f0000ff, 1), "Got unexpected color 0x%08x.\n", color);
color = get_texture_color(backbuffer_0, 320, 240); /* blue */
ok(compare_color(color, 0x7fff0000, 1), "Got unexpected color 0x%08x.\n", color);
......
......@@ -6173,7 +6173,7 @@ static void test_swapchain_flip(void)
color = get_texture_color(offscreen, 120, 240); /* blue, buf 0 */
todo_wine ok(compare_color(color, 0x7fff0000, 1), "Got unexpected color 0x%08x.\n", color);
color = get_texture_color(offscreen, 360, 240); /* red, buf 1 */
todo_wine ok(compare_color(color, 0x7f0000ff, 1), "Got unexpected color 0x%08x.\n", color);
ok(compare_color(color, 0x7f0000ff, 1), "Got unexpected color 0x%08x.\n", color);
color = get_texture_color(backbuffer_0, 320, 240); /* blue */
ok(compare_color(color, 0x7fff0000, 1), "Got unexpected color 0x%08x.\n", color);
......
......@@ -3339,18 +3339,11 @@ static void context_bind_shader_resources(struct wined3d_context *context, const
}
if (entry->sampler_idx == WINED3D_SAMPLER_DEFAULT)
{
sampler_name = device->default_sampler;
}
else if ((sampler = state->sampler[shader_types[i].type][entry->sampler_idx]))
{
sampler_name = sampler->name;
}
else
{
WARN("No sampler object bound at index %u, %u.\n", shader_types[i].type, entry->sampler_idx);
continue;
}
sampler_name = device->null_sampler;
texture = texture_from_resource(view->resource);
context_active_texture(context, gl_info, shader_types[i].base_idx + entry->bind_idx);
......
......@@ -814,43 +814,52 @@ static void destroy_dummy_textures(struct wined3d_device *device, const struct w
}
/* Context activation is done by the caller. */
static void create_default_sampler(struct wined3d_device *device)
static void create_default_samplers(struct wined3d_device *device)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
/*
* In SM4+ shaders there is a separation between resources and samplers. Some shader
* instructions allow access to resources without using samplers.
* In GLSL, resources are always accessed through sampler or image variables. The default
* sampler object is used to emulate the direct resource access when there is no sampler state
* to use.
*/
if (gl_info->supported[ARB_SAMPLER_OBJECTS])
{
/* In SM4+ shaders there is a separation between resources and samplers. Some shader
* instructions allow access to resources without using samplers.
* In GLSL, resources are always accessed through sampler or image variables. The default
* sampler object is used to emulate the direct resource access when there is no sampler state
* to use.
*/
GL_EXTCALL(glGenSamplers(1, &device->default_sampler));
checkGLcall("glGenSamplers");
GL_EXTCALL(glSamplerParameteri(device->default_sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST));
GL_EXTCALL(glSamplerParameteri(device->default_sampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST));
checkGLcall("glSamplerParameteri");
checkGLcall("Create default sampler");
/* In D3D10+, a NULL sampler maps to the default sampler state. */
GL_EXTCALL(glGenSamplers(1, &device->null_sampler));
GL_EXTCALL(glSamplerParameteri(device->null_sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR));
GL_EXTCALL(glSamplerParameteri(device->null_sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
GL_EXTCALL(glSamplerParameteri(device->null_sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
GL_EXTCALL(glSamplerParameteri(device->null_sampler, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE));
checkGLcall("Create null sampler");
}
else
{
device->default_sampler = 0;
device->null_sampler = 0;
}
}
/* Context activation is done by the caller. */
static void destroy_default_sampler(struct wined3d_device *device)
static void destroy_default_samplers(struct wined3d_device *device)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
if (gl_info->supported[ARB_SAMPLER_OBJECTS])
{
GL_EXTCALL(glDeleteSamplers(1, &device->default_sampler));
GL_EXTCALL(glDeleteSamplers(1, &device->null_sampler));
checkGLcall("glDeleteSamplers");
}
device->default_sampler = 0;
device->null_sampler = 0;
}
static LONG fullscreen_style(LONG style)
......@@ -1058,7 +1067,7 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
context = context_acquire(device, swapchain->front_buffer->sub_resources[0].u.surface);
create_dummy_textures(device, context);
create_default_sampler(device);
create_default_samplers(device);
device->contexts[0]->last_was_rhw = 0;
......@@ -1183,7 +1192,7 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device)
device->blitter->free_private(device);
device->shader_backend->shader_free_private(device);
destroy_dummy_textures(device, gl_info);
destroy_default_sampler(device);
destroy_default_samplers(device);
/* Release the context again as soon as possible. In particular,
* releasing the render target views below may release the last reference
......@@ -4548,7 +4557,7 @@ static void delete_opengl_contexts(struct wined3d_device *device, struct wined3d
device->blitter->free_private(device);
device->shader_backend->shader_free_private(device);
destroy_dummy_textures(device, gl_info);
destroy_default_sampler(device);
destroy_default_samplers(device);
context_release(context);
......@@ -4604,7 +4613,7 @@ static HRESULT create_primary_opengl_context(struct wined3d_device *device, stru
swapchain->context[0] = context;
swapchain->num_contexts = 1;
create_dummy_textures(device, context);
create_default_sampler(device);
create_default_samplers(device);
context_release(context);
return WINED3D_OK;
......
......@@ -2351,6 +2351,7 @@ struct wined3d_device
/* Default sampler used to emulate the direct resource access without using wined3d_sampler */
GLuint default_sampler;
GLuint null_sampler;
/* Command stream */
struct wined3d_cs *cs;
......
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