Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/directx.c | 2 ++ dlls/wined3d/glsl_shader.c | 43 ++++++++++++++++++++++++++++++++++++++++++- dlls/wined3d/shader.c | 3 ++- dlls/wined3d/wined3d_gl.h | 1 + 4 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index c058737165ba..74d4d19d3795 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -162,6 +162,7 @@ static const struct wined3d_extension_map gl_extension_map[] = {"GL_ARB_shader_image_load_store", ARB_SHADER_IMAGE_LOAD_STORE }, {"GL_ARB_shader_image_size", ARB_SHADER_IMAGE_SIZE }, {"GL_ARB_shader_storage_buffer_object", ARB_SHADER_STORAGE_BUFFER_OBJECT}, + {"GL_ARB_shader_texture_image_samples", ARB_SHADER_TEXTURE_IMAGE_SAMPLES}, {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD }, {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100 }, {"GL_ARB_shading_language_420pack", ARB_SHADING_LANGUAGE_420PACK }, @@ -3938,6 +3939,7 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter, {ARB_CLIP_CONTROL, MAKEDWORD_VERSION(4, 5)}, {ARB_CULL_DISTANCE, MAKEDWORD_VERSION(4, 5)}, {ARB_DERIVATIVE_CONTROL, MAKEDWORD_VERSION(4, 5)}, + {ARB_SHADER_TEXTURE_IMAGE_SAMPLES, MAKEDWORD_VERSION(4, 5)},
{ARB_PIPELINE_STATISTICS_QUERY, MAKEDWORD_VERSION(4, 6)}, {ARB_TEXTURE_FILTER_ANISOTROPIC, MAKEDWORD_VERSION(4, 6)}, diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index eddf35d83a04..40d19d028ffe 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -6022,6 +6022,45 @@ static void shader_glsl_resinfo(const struct wined3d_shader_instruction *ins) shader_addline(buffer, ")%s);\n", dst_swizzle); }
+static void shader_glsl_sample_info(const struct wined3d_shader_instruction *ins) +{ + const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps; + const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; + struct wined3d_string_buffer *buffer = ins->ctx->buffer; + enum wined3d_shader_resource_type resource_type; + enum wined3d_data_type dst_data_type; + unsigned int resource_idx, bind_idx; + char dst_swizzle[6]; + DWORD write_mask; + + if (!gl_info->supported[ARB_SHADER_TEXTURE_IMAGE_SAMPLES]) + { + FIXME("textureSamples() is not supported.\n"); + return; + } + + dst_data_type = ins->dst[0].reg.data_type; + if (ins->flags == WINED3DSI_SAMPLE_INFO_UINT) + dst_data_type = WINED3D_DATA_UINT; + else if (ins->flags) + FIXME("Unhandled flags %#x.\n", ins->flags); + + resource_idx = ins->src[0].reg.idx[0].offset; + resource_type = reg_maps->resource_info[resource_idx].type; + if (resource_type >= ARRAY_SIZE(resource_type_info)) + { + ERR("Unexpected resource type %#x.\n", resource_type); + return; + } + bind_idx = shader_glsl_find_sampler(®_maps->sampler_map, resource_idx, WINED3D_SAMPLER_DEFAULT); + + write_mask = shader_glsl_append_dst_ext(buffer, ins, &ins->dst[0], dst_data_type); + shader_glsl_get_swizzle(&ins->src[0], FALSE, write_mask, dst_swizzle); + shader_addline(buffer, "%s(textureSamples(%s_sampler%u), 0, 0, 0)%s);\n", + dst_data_type == WINED3D_DATA_UINT ? "uvec4" : "vec4", + shader_glsl_get_prefix(reg_maps->shader_version.type), bind_idx, dst_swizzle); +} + static void shader_glsl_ld(const struct wined3d_shader_instruction *ins) { const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps; @@ -7514,6 +7553,8 @@ static void shader_glsl_enable_extensions(struct wined3d_string_buffer *buffer, shader_addline(buffer, "#extension GL_ARB_shader_image_size : enable\n"); if (gl_info->supported[ARB_SHADER_STORAGE_BUFFER_OBJECT]) shader_addline(buffer, "#extension GL_ARB_shader_storage_buffer_object : enable\n"); + if (gl_info->supported[ARB_SHADER_TEXTURE_IMAGE_SAMPLES]) + shader_addline(buffer, "#extension GL_ARB_shader_texture_image_samples : enable\n"); if (gl_info->supported[ARB_SHADING_LANGUAGE_420PACK]) shader_addline(buffer, "#extension GL_ARB_shading_language_420pack : enable\n"); if (gl_info->supported[ARB_SHADING_LANGUAGE_PACKING]) @@ -11309,7 +11350,7 @@ static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TAB /* WINED3DSIH_SAMPLE_C */ shader_glsl_sample_c, /* WINED3DSIH_SAMPLE_C_LZ */ shader_glsl_sample_c, /* WINED3DSIH_SAMPLE_GRAD */ shader_glsl_sample, - /* WINED3DSIH_SAMPLE_INFO */ NULL, + /* WINED3DSIH_SAMPLE_INFO */ shader_glsl_sample_info, /* WINED3DSIH_SAMPLE_LOD */ shader_glsl_sample, /* WINED3DSIH_SAMPLE_POS */ NULL, /* WINED3DSIH_SETP */ NULL, diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index 3750deea148a..be1b5962ed5d 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -1712,7 +1712,8 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, DWORD co shader_record_sample(reg_maps, ins.src[2].reg.idx[0].offset, ins.src[3].reg.idx[0].offset, reg_maps->sampler_map.count); } - else if (ins.handler_idx == WINED3DSIH_BUFINFO && ins.src[0].reg.type == WINED3DSPR_RESOURCE) + else if ((ins.handler_idx == WINED3DSIH_BUFINFO && ins.src[0].reg.type == WINED3DSPR_RESOURCE) + || ins.handler_idx == WINED3DSIH_SAMPLE_INFO) { shader_record_sample(reg_maps, ins.src[0].reg.idx[0].offset, WINED3D_SAMPLER_DEFAULT, reg_maps->sampler_map.count); diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h index 49205f9c1205..db1929dbcbce 100644 --- a/dlls/wined3d/wined3d_gl.h +++ b/dlls/wined3d/wined3d_gl.h @@ -95,6 +95,7 @@ enum wined3d_gl_extension ARB_SHADER_IMAGE_LOAD_STORE, ARB_SHADER_IMAGE_SIZE, ARB_SHADER_STORAGE_BUFFER_OBJECT, + ARB_SHADER_TEXTURE_IMAGE_SAMPLES, ARB_SHADER_TEXTURE_LOD, ARB_SHADING_LANGUAGE_100, ARB_SHADING_LANGUAGE_420PACK,
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/texture.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index dadcd0323a0f..0b0545394cc7 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1919,15 +1919,20 @@ void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int s target = wined3d_texture_get_sub_resource_target(texture, sub_resource_idx); level = sub_resource_idx % texture->level_count;
- if (target == GL_TEXTURE_1D_ARRAY) - { - dst_y = sub_resource_idx / texture->level_count; - update_h = 1; - } - else if (target == GL_TEXTURE_2D_ARRAY) + switch (target) { - dst_z = sub_resource_idx / texture->level_count; - update_d = 1; + case GL_TEXTURE_1D_ARRAY: + dst_y = sub_resource_idx / texture->level_count; + update_h = 1; + break; + case GL_TEXTURE_2D_ARRAY: + dst_z = sub_resource_idx / texture->level_count; + update_d = 1; + break; + case GL_TEXTURE_2D_MULTISAMPLE: + case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: + FIXME("Not supported for multisample textures.\n"); + return; }
bo.buffer_object = data->buffer_object;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/d3d11/tests/d3d11.c | 138 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 63f964a46140..6c37227106fe 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -19813,6 +19813,143 @@ static void test_sm5_bufinfo_instruction(void) release_test_context(&test_context); }
+static void test_sampleinfo_instruction(void) +{ + ID3D11Texture2D *float_rt_texture, *uint_rt_texture; + ID3D11RenderTargetView *float_rtv, *uint_rtv; + struct d3d11_test_context test_context; + ID3D11PixelShader *ps_float, *ps_uint; + unsigned int sample_count, quality; + D3D11_TEXTURE2D_DESC texture_desc; + ID3D11RenderTargetView *rtvs[2]; + ID3D11ShaderResourceView *srv; + ID3D11DeviceContext *context; + struct uvec4 expected_uint; + struct vec4 expected_float; + ID3D11Resource *texture; + ID3D11Device *device; + HRESULT hr; + + static const DWORD ps_uint_code[] = + { +#if 0 + Texture2DMS<float> t; + + uint4 main() : SV_Target1 + { + uint width, height, sample_count; + t.GetDimensions(width, height, sample_count); + return sample_count; + } +#endif + 0x43425844, 0x4342ad12, 0x19addd8c, 0x5cb87c48, 0xe604a242, 0x00000001, 0x000000d4, 0x00000003, + 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000001, 0x00000000, 0x00000001, 0x00000001, + 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x0000005c, 0x00000050, 0x00000017, + 0x0100086a, 0x04002058, 0x00107000, 0x00000000, 0x00005555, 0x03000065, 0x001020f2, 0x00000001, + 0x02000068, 0x00000001, 0x0500086f, 0x00100012, 0x00000000, 0x0010700a, 0x00000000, 0x05000036, + 0x001020f2, 0x00000001, 0x00100006, 0x00000000, 0x0100003e, + }; + static const DWORD ps_float_code[] = + { +#if 0 + Texture2DMS<float> t; + + float4 main() : SV_Target + { + uint width, height, sample_count; + t.GetDimensions(width, height, sample_count); + return sample_count; + } +#endif + 0x43425844, 0x2b8aea46, 0x34ceda6f, 0xf98d222b, 0x235ebc0b, 0x00000001, 0x000000b8, 0x00000003, + 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000040, 0x00000050, 0x00000010, + 0x0100086a, 0x04002058, 0x00107000, 0x00000000, 0x00005555, 0x03000065, 0x001020f2, 0x00000000, + 0x0500006f, 0x001020f2, 0x00000000, 0x0010700a, 0x00000000, 0x0100003e, + }; + static const D3D_FEATURE_LEVEL feature_level = D3D_FEATURE_LEVEL_11_0; + + if (!init_test_context(&test_context, &feature_level)) + return; + + device = test_context.device; + context = test_context.immediate_context; + + texture_desc.Width = 64; + texture_desc.Height = 64; + texture_desc.MipLevels = 1; + texture_desc.ArraySize = 1; + texture_desc.SampleDesc.Count = 1; + texture_desc.SampleDesc.Quality = 0; + texture_desc.Usage = D3D11_USAGE_DEFAULT; + texture_desc.BindFlags = D3D11_BIND_RENDER_TARGET; + texture_desc.CPUAccessFlags = 0; + texture_desc.MiscFlags = 0; + + texture_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; + hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &float_rt_texture); + ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr); + hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)float_rt_texture, NULL, &float_rtv); + ok(hr == S_OK, "Failed to create rendertarget view, hr %#x.\n", hr); + texture_desc.Format = DXGI_FORMAT_R32G32B32A32_UINT; + hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &uint_rt_texture); + ok(hr == S_OK, "Failed to create texture, hr %#x.\n", hr); + hr = ID3D11Device_CreateRenderTargetView(device, (ID3D11Resource *)uint_rt_texture, NULL, &uint_rtv); + ok(hr == S_OK, "Failed to create rendertarget view, hr %#x.\n", hr); + + rtvs[0] = float_rtv; + rtvs[1] = uint_rtv; + ID3D11DeviceContext_OMSetRenderTargets(context, ARRAY_SIZE(rtvs), rtvs, NULL); + + hr = ID3D11Device_CreatePixelShader(device, ps_float_code, sizeof(ps_float_code), NULL, &ps_float); + ok(hr == S_OK, "Failed to create pixel shader, hr %#x.\n", hr); + hr = ID3D11Device_CreatePixelShader(device, ps_uint_code, sizeof(ps_uint_code), NULL, &ps_uint); + ok(hr == S_OK, "Failed to create pixel shader, hr %#x.\n", hr); + + for (sample_count = 2; sample_count <= 8; sample_count *= 2) + { + texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + texture_desc.SampleDesc.Count = sample_count; + texture_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; + + if (FAILED(hr = ID3D11Device_CheckMultisampleQualityLevels(device, + texture_desc.Format, sample_count, &quality))) + { + skip("Sample count %u not supported.\n", sample_count); + continue; + } + + hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, (ID3D11Texture2D **)&texture); + ok(hr == S_OK, "Failed to create texture, hr %#x, sample count %u.\n", hr, sample_count); + hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)texture, NULL, &srv); + ok(hr == S_OK, "Failed to create shader resource view, hr %#x.\n", hr); + ID3D11DeviceContext_PSSetShaderResources(context, 0, 1, &srv); + + ID3D11DeviceContext_PSSetShader(context, ps_float, NULL, 0); + draw_quad(&test_context); + ID3D11DeviceContext_PSSetShader(context, ps_uint, NULL, 0); + draw_quad(&test_context); + + expected_float.x = expected_float.y = expected_float.z = expected_float.w = sample_count; + check_texture_vec4(float_rt_texture, &expected_float, 0); + expected_uint.x = expected_uint.y = expected_uint.z = expected_uint.w = sample_count; + check_texture_uvec4(uint_rt_texture, &expected_uint); + + ID3D11Resource_Release(texture); + ID3D11ShaderResourceView_Release(srv); + } + + ID3D11RenderTargetView_Release(float_rtv); + ID3D11RenderTargetView_Release(uint_rtv); + ID3D11Texture2D_Release(float_rt_texture); + ID3D11Texture2D_Release(uint_rt_texture); + ID3D11PixelShader_Release(ps_float); + ID3D11PixelShader_Release(ps_uint); + release_test_context(&test_context); +} + static void test_render_target_device_mismatch(void) { struct d3d11_test_context test_context; @@ -26675,6 +26812,7 @@ START_TEST(d3d11) test_primitive_restart(); test_resinfo_instruction(); test_sm5_bufinfo_instruction(); + test_sampleinfo_instruction(); test_render_target_device_mismatch(); test_buffer_srv(); run_for_each_feature_level_in_range(D3D_FEATURE_LEVEL_10_0, D3D_FEATURE_LEVEL_11_0,
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/directx.c | 4 ++++ dlls/wined3d/glsl_shader.c | 2 ++ dlls/wined3d/wined3d_gl.h | 1 + 3 files changed, 7 insertions(+)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 74d4d19d3795..e125c5ff6ef4 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -155,6 +155,7 @@ static const struct wined3d_extension_map gl_extension_map[] = {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS }, {"GL_ARB_point_sprite", ARB_POINT_SPRITE }, {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX }, + {"GL_ARB_sample_shading", ARB_SAMPLE_SHADING }, {"GL_ARB_sampler_objects", ARB_SAMPLER_OBJECTS }, {"GL_ARB_seamless_cube_map", ARB_SEAMLESS_CUBE_MAP }, {"GL_ARB_shader_atomic_counters", ARB_SHADER_ATOMIC_COUNTERS }, @@ -2813,6 +2814,8 @@ static void load_gl_funcs(struct wined3d_gl_info *gl_info) USE_GL_FUNC(glPointParameterfvARB) /* GL_ARB_provoking_vertex */ USE_GL_FUNC(glProvokingVertex) + /* GL_ARB_sample_shading */ + USE_GL_FUNC(glMinSampleShadingARB) /* GL_ARB_sampler_objects */ USE_GL_FUNC(glGenSamplers) USE_GL_FUNC(glDeleteSamplers) @@ -3898,6 +3901,7 @@ static BOOL wined3d_adapter_init_gl_caps(struct wined3d_adapter *adapter,
{ARB_DRAW_INDIRECT, MAKEDWORD_VERSION(4, 0)}, {ARB_GPU_SHADER5, MAKEDWORD_VERSION(4, 0)}, + {ARB_SAMPLE_SHADING, MAKEDWORD_VERSION(4, 0)}, {ARB_TESSELLATION_SHADER, MAKEDWORD_VERSION(4, 0)}, {ARB_TEXTURE_CUBE_MAP_ARRAY, MAKEDWORD_VERSION(4, 0)}, {ARB_TEXTURE_GATHER, MAKEDWORD_VERSION(4, 0)}, diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 40d19d028ffe..2a57acd2ef62 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -7629,6 +7629,8 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context shader_addline(buffer, "#extension GL_ARB_fragment_coord_conventions : enable\n"); if (gl_info->supported[ARB_FRAGMENT_LAYER_VIEWPORT]) shader_addline(buffer, "#extension GL_ARB_fragment_layer_viewport : enable\n"); + if (gl_info->supported[ARB_SAMPLE_SHADING]) + shader_addline(buffer, "#extension GL_ARB_sample_shading : enable\n"); if (gl_info->supported[ARB_SHADER_TEXTURE_LOD]) shader_addline(buffer, "#extension GL_ARB_shader_texture_lod : enable\n"); /* The spec says that it doesn't have to be explicitly enabled, but the diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h index db1929dbcbce..3140526ca11a 100644 --- a/dlls/wined3d/wined3d_gl.h +++ b/dlls/wined3d/wined3d_gl.h @@ -88,6 +88,7 @@ enum wined3d_gl_extension ARB_POINT_PARAMETERS, ARB_POINT_SPRITE, ARB_PROVOKING_VERTEX, + ARB_SAMPLE_SHADING, ARB_SAMPLER_OBJECTS, ARB_SEAMLESS_CUBE_MAP, ARB_SHADER_ATOMIC_COUNTERS,
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/glsl_shader.c | 62 ++++++++++++++++++++++++++++++------------ dlls/wined3d/shader.c | 6 +++- dlls/wined3d/shader_sm4.c | 3 +- dlls/wined3d/wined3d_private.h | 1 + 4 files changed, 52 insertions(+), 20 deletions(-)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 2a57acd2ef62..7a7764b6438a 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -6027,38 +6027,64 @@ static void shader_glsl_sample_info(const struct wined3d_shader_instruction *ins const struct wined3d_shader_reg_maps *reg_maps = ins->ctx->reg_maps; const struct wined3d_gl_info *gl_info = ins->ctx->gl_info; struct wined3d_string_buffer *buffer = ins->ctx->buffer; + const struct wined3d_shader_dst_param *dst = ins->dst; + const struct wined3d_shader_src_param *src = ins->src; enum wined3d_shader_resource_type resource_type; enum wined3d_data_type dst_data_type; unsigned int resource_idx, bind_idx; char dst_swizzle[6]; DWORD write_mask;
- if (!gl_info->supported[ARB_SHADER_TEXTURE_IMAGE_SAMPLES]) - { - FIXME("textureSamples() is not supported.\n"); - return; - } - - dst_data_type = ins->dst[0].reg.data_type; + dst_data_type = dst->reg.data_type; if (ins->flags == WINED3DSI_SAMPLE_INFO_UINT) dst_data_type = WINED3D_DATA_UINT; else if (ins->flags) FIXME("Unhandled flags %#x.\n", ins->flags);
- resource_idx = ins->src[0].reg.idx[0].offset; - resource_type = reg_maps->resource_info[resource_idx].type; - if (resource_type >= ARRAY_SIZE(resource_type_info)) + write_mask = shader_glsl_append_dst_ext(buffer, ins, dst, dst_data_type); + shader_glsl_get_swizzle(src, FALSE, write_mask, dst_swizzle); + + if (dst_data_type == WINED3D_DATA_UINT) + shader_addline(buffer, "uvec4("); + else + shader_addline(buffer, "vec4("); + + if (src->reg.type == WINED3DSPR_RASTERIZER) { - ERR("Unexpected resource type %#x.\n", resource_type); - return; + if (gl_info->supported[ARB_SAMPLE_SHADING]) + { + shader_addline(buffer, "gl_NumSamples"); + } + else + { + FIXME("OpenGL implementation does not support ARB_sample_shading.\n"); + shader_addline(buffer, "1"); + } } - bind_idx = shader_glsl_find_sampler(®_maps->sampler_map, resource_idx, WINED3D_SAMPLER_DEFAULT); + else + { + resource_idx = src->reg.idx[0].offset; + resource_type = reg_maps->resource_info[resource_idx].type; + if (resource_type >= ARRAY_SIZE(resource_type_info)) + { + ERR("Unexpected resource type %#x.\n", resource_type); + return; + } + bind_idx = shader_glsl_find_sampler(®_maps->sampler_map, resource_idx, WINED3D_SAMPLER_DEFAULT);
- write_mask = shader_glsl_append_dst_ext(buffer, ins, &ins->dst[0], dst_data_type); - shader_glsl_get_swizzle(&ins->src[0], FALSE, write_mask, dst_swizzle); - shader_addline(buffer, "%s(textureSamples(%s_sampler%u), 0, 0, 0)%s);\n", - dst_data_type == WINED3D_DATA_UINT ? "uvec4" : "vec4", - shader_glsl_get_prefix(reg_maps->shader_version.type), bind_idx, dst_swizzle); + if (gl_info->supported[ARB_SHADER_TEXTURE_IMAGE_SAMPLES]) + { + shader_addline(buffer, "textureSamples(%s_sampler%u)", + shader_glsl_get_prefix(reg_maps->shader_version.type), bind_idx); + } + else + { + FIXME("textureSamples() is not supported.\n"); + shader_addline(buffer, "1"); + } + } + + shader_addline(buffer, ", 0, 0, 0)%s);\n", dst_swizzle); }
static void shader_glsl_ld(const struct wined3d_shader_instruction *ins) diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c index be1b5962ed5d..45ae04a9bec9 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c @@ -1713,7 +1713,7 @@ static HRESULT shader_get_registers_used(struct wined3d_shader *shader, DWORD co ins.src[3].reg.idx[0].offset, reg_maps->sampler_map.count); } else if ((ins.handler_idx == WINED3DSIH_BUFINFO && ins.src[0].reg.type == WINED3DSPR_RESOURCE) - || ins.handler_idx == WINED3DSIH_SAMPLE_INFO) + || (ins.handler_idx == WINED3DSIH_SAMPLE_INFO && ins.src[0].reg.type == WINED3DSPR_RESOURCE)) { shader_record_sample(reg_maps, ins.src[0].reg.idx[0].offset, WINED3D_SAMPLER_DEFAULT, reg_maps->sampler_map.count); @@ -2337,6 +2337,10 @@ static void shader_dump_register(struct wined3d_string_buffer *buffer, shader_addline(buffer, "null"); break;
+ case WINED3DSPR_RASTERIZER: + shader_addline(buffer, "rasterizer"); + break; + case WINED3DSPR_RESOURCE: shader_addline(buffer, "t"); break; diff --git a/dlls/wined3d/shader_sm4.c b/dlls/wined3d/shader_sm4.c index b56f16a64e1d..b119e8feaa80 100644 --- a/dlls/wined3d/shader_sm4.c +++ b/dlls/wined3d/shader_sm4.c @@ -318,6 +318,7 @@ enum wined3d_sm4_register_type WINED3D_SM4_RT_PRIMID = 0x0b, WINED3D_SM4_RT_DEPTHOUT = 0x0c, WINED3D_SM4_RT_NULL = 0x0d, + WINED3D_SM4_RT_RASTERIZER = 0x0e, WINED3D_SM4_RT_OMASK = 0x0f, WINED3D_SM5_RT_STREAM = 0x10, WINED3D_SM5_RT_FUNCTION_BODY = 0x11, @@ -1132,7 +1133,7 @@ static const enum wined3d_shader_register_type register_type_table[] = /* WINED3D_SM4_RT_PRIMID */ WINED3DSPR_PRIMID, /* WINED3D_SM4_RT_DEPTHOUT */ WINED3DSPR_DEPTHOUT, /* WINED3D_SM4_RT_NULL */ WINED3DSPR_NULL, - /* UNKNOWN */ ~0u, + /* WINED3D_SM4_RT_RASTERIZER */ WINED3DSPR_RASTERIZER, /* WINED3D_SM4_RT_OMASK */ WINED3DSPR_SAMPLEMASK, /* WINED3D_SM5_RT_STREAM */ WINED3DSPR_STREAM, /* WINED3D_SM5_RT_FUNCTION_BODY */ WINED3DSPR_FUNCTIONBODY, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index bb20842342f9..b2e4372e9ae5 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -497,6 +497,7 @@ enum wined3d_shader_register_type WINED3DSPR_GSINSTID, WINED3DSPR_DEPTHOUTGE, WINED3DSPR_DEPTHOUTLE, + WINED3DSPR_RASTERIZER, };
enum wined3d_data_type
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com