From cb1e492ee0b65c05bcc233236b5b3ce740b2abee Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Wed, 1 Jul 2020 14:21:09 +0200 Subject: [PATCH] v3dv: handle unnormalized coordinates in samplers In OpenGL, unnormalized coordinates are implicit based on the sampler type (rectangle textures), so the compiler can set the flag when needed. In Vulkan, however, this is configured explicitly in the sampler object, so the compiler won't set it and we need to do it manually when we are writing the P1 uniform. Fixes: dEQP-VK.pipeline.sampler.exact_sampling.*.unnormalized_coords Part-of: --- src/broadcom/vulkan/v3dv_device.c | 1 + src/broadcom/vulkan/v3dv_private.h | 1 + src/broadcom/vulkan/v3dv_uniforms.c | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c index 800b89eb103..aa4e75310b0 100644 --- a/src/broadcom/vulkan/v3dv_device.c +++ b/src/broadcom/vulkan/v3dv_device.c @@ -2086,6 +2086,7 @@ v3dv_CreateSampler(VkDevice _device, return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); sampler->compare_enable = pCreateInfo->compareEnable; + sampler->unnormalized_coordinates = pCreateInfo->unnormalizedCoordinates; pack_sampler_state(sampler, pCreateInfo); *pSampler = v3dv_sampler_to_handle(sampler); diff --git a/src/broadcom/vulkan/v3dv_private.h b/src/broadcom/vulkan/v3dv_private.h index bc48c81c2b4..f53b7a6f4a8 100644 --- a/src/broadcom/vulkan/v3dv_private.h +++ b/src/broadcom/vulkan/v3dv_private.h @@ -1375,6 +1375,7 @@ struct v3dv_descriptor_map { struct v3dv_sampler { bool compare_enable; + bool unnormalized_coordinates; /* Prepacked SAMPLER_STATE, that is referenced as part of the tmu * configuration. If needed it will be copied to the descriptor info during diff --git a/src/broadcom/vulkan/v3dv_uniforms.c b/src/broadcom/vulkan/v3dv_uniforms.c index f1117fcb87d..a3ad5c2d13b 100644 --- a/src/broadcom/vulkan/v3dv_uniforms.c +++ b/src/broadcom/vulkan/v3dv_uniforms.c @@ -140,10 +140,25 @@ write_tmu_p1(struct v3dv_cmd_buffer *cmd_buffer, v3dv_descriptor_map_get_sampler_state(descriptor_state, &pipeline->sampler_map, pipeline->layout, sampler_idx); + const struct v3dv_sampler *sampler = + v3dv_descriptor_map_get_sampler(descriptor_state, &pipeline->sampler_map, + pipeline->layout, sampler_idx); + assert(sampler); + + /* Set unnormalized coordinates flag from sampler object */ + uint32_t p1_packed = v3d_unit_data_get_offset(data); + if (sampler->unnormalized_coordinates) { + struct V3DX(TMU_CONFIG_PARAMETER_1) p1_unpacked; + V3DX(TMU_CONFIG_PARAMETER_1_unpack)((uint8_t *)&p1_packed, &p1_unpacked); + p1_unpacked.unnormalized_coordinates = true; + V3DX(TMU_CONFIG_PARAMETER_1_pack)(NULL, (uint8_t *)&p1_packed, + &p1_unpacked); + } + cl_aligned_reloc(&job->indirect, uniforms, sampler_state_reloc.bo, sampler_state_reloc.offset + - v3d_unit_data_get_offset(data)); + p1_packed); } static void