summaryrefslogtreecommitdiffstats
path: root/src/intel
diff options
context:
space:
mode:
authorLionel Landwerlin <[email protected]>2017-09-25 18:47:33 +0100
committerLionel Landwerlin <[email protected]>2017-10-06 16:32:19 +0100
commit3492d560671c09a4d42630cbf51ceaefc99b9db6 (patch)
tree258b772a733e7053036a1060579a0fce92bbaa4e /src/intel
parenta2a7846d37012645975381263be27af4e31901ea (diff)
anv: prepare sampler emission code for multiplanar images
New settings from the KHR_sampler_ycbcr_conversion specifications might require different sampler settings for luma and chroma planes. This change makes the sampler table emission ready to handle multiple planes. Signed-off-by: Lionel Landwerlin <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/intel')
-rw-r--r--src/intel/vulkan/anv_private.h2
-rw-r--r--src/intel/vulkan/genX_cmd_buffer.c2
-rw-r--r--src/intel/vulkan/genX_state.c80
3 files changed, 43 insertions, 41 deletions
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index ff1b1cc8a80..5dde45f7cb9 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -2545,7 +2545,7 @@ void anv_fill_buffer_surface_state(struct anv_device *device,
uint32_t stride);
struct anv_sampler {
- uint32_t state[4];
+ uint32_t state[3][4];
uint32_t n_planes;
};
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 35593990198..f19746db442 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -1742,7 +1742,7 @@ emit_samplers(struct anv_cmd_buffer *cmd_buffer,
continue;
memcpy(state->map + (s * 16),
- sampler->state, sizeof(sampler->state));
+ sampler->state[binding->plane], sizeof(sampler->state[0]));
}
anv_state_flush(cmd_buffer->device, *state);
diff --git a/src/intel/vulkan/genX_state.c b/src/intel/vulkan/genX_state.c
index 81570825a54..91da05cddbf 100644
--- a/src/intel/vulkan/genX_state.c
+++ b/src/intel/vulkan/genX_state.c
@@ -166,7 +166,7 @@ VkResult genX(CreateSampler)(
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO);
- sampler = vk_alloc2(&device->alloc, pAllocator, sizeof(*sampler), 8,
+ sampler = vk_zalloc2(&device->alloc, pAllocator, sizeof(*sampler), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!sampler)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
@@ -181,55 +181,57 @@ VkResult genX(CreateSampler)(
bool enable_mag_filter_addr_rounding =
pCreateInfo->magFilter != VK_FILTER_NEAREST;
- struct GENX(SAMPLER_STATE) sampler_state = {
- .SamplerDisable = false,
- .TextureBorderColorMode = DX10OGL,
+ for (unsigned p = 0; p < sampler->n_planes; p++) {
+ struct GENX(SAMPLER_STATE) sampler_state = {
+ .SamplerDisable = false,
+ .TextureBorderColorMode = DX10OGL,
#if GEN_GEN >= 8
- .LODPreClampMode = CLAMP_MODE_OGL,
+ .LODPreClampMode = CLAMP_MODE_OGL,
#else
- .LODPreClampEnable = CLAMP_ENABLE_OGL,
+ .LODPreClampEnable = CLAMP_ENABLE_OGL,
#endif
#if GEN_GEN == 8
- .BaseMipLevel = 0.0,
+ .BaseMipLevel = 0.0,
#endif
- .MipModeFilter = vk_to_gen_mipmap_mode[pCreateInfo->mipmapMode],
- .MagModeFilter = vk_to_gen_tex_filter(pCreateInfo->magFilter,
- pCreateInfo->anisotropyEnable),
- .MinModeFilter = vk_to_gen_tex_filter(pCreateInfo->minFilter,
- pCreateInfo->anisotropyEnable),
- .TextureLODBias = anv_clamp_f(pCreateInfo->mipLodBias, -16, 15.996),
- .AnisotropicAlgorithm = EWAApproximation,
- .MinLOD = anv_clamp_f(pCreateInfo->minLod, 0, 14),
- .MaxLOD = anv_clamp_f(pCreateInfo->maxLod, 0, 14),
- .ChromaKeyEnable = 0,
- .ChromaKeyIndex = 0,
- .ChromaKeyMode = 0,
- .ShadowFunction = vk_to_gen_shadow_compare_op[pCreateInfo->compareOp],
- .CubeSurfaceControlMode = OVERRIDE,
-
- .BorderColorPointer = border_color_offset,
+ .MipModeFilter = vk_to_gen_mipmap_mode[pCreateInfo->mipmapMode],
+ .MagModeFilter = vk_to_gen_tex_filter(pCreateInfo->magFilter,
+ pCreateInfo->anisotropyEnable),
+ .MinModeFilter = vk_to_gen_tex_filter(pCreateInfo->minFilter,
+ pCreateInfo->anisotropyEnable),
+ .TextureLODBias = anv_clamp_f(pCreateInfo->mipLodBias, -16, 15.996),
+ .AnisotropicAlgorithm = EWAApproximation,
+ .MinLOD = anv_clamp_f(pCreateInfo->minLod, 0, 14),
+ .MaxLOD = anv_clamp_f(pCreateInfo->maxLod, 0, 14),
+ .ChromaKeyEnable = 0,
+ .ChromaKeyIndex = 0,
+ .ChromaKeyMode = 0,
+ .ShadowFunction = vk_to_gen_shadow_compare_op[pCreateInfo->compareOp],
+ .CubeSurfaceControlMode = OVERRIDE,
+
+ .BorderColorPointer = border_color_offset,
#if GEN_GEN >= 8
- .LODClampMagnificationMode = MIPNONE,
+ .LODClampMagnificationMode = MIPNONE,
#endif
- .MaximumAnisotropy = vk_to_gen_max_anisotropy(pCreateInfo->maxAnisotropy),
- .RAddressMinFilterRoundingEnable = enable_min_filter_addr_rounding,
- .RAddressMagFilterRoundingEnable = enable_mag_filter_addr_rounding,
- .VAddressMinFilterRoundingEnable = enable_min_filter_addr_rounding,
- .VAddressMagFilterRoundingEnable = enable_mag_filter_addr_rounding,
- .UAddressMinFilterRoundingEnable = enable_min_filter_addr_rounding,
- .UAddressMagFilterRoundingEnable = enable_mag_filter_addr_rounding,
- .TrilinearFilterQuality = 0,
- .NonnormalizedCoordinateEnable = pCreateInfo->unnormalizedCoordinates,
- .TCXAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressModeU],
- .TCYAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressModeV],
- .TCZAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressModeW],
- };
-
- GENX(SAMPLER_STATE_pack)(NULL, sampler->state, &sampler_state);
+ .MaximumAnisotropy = vk_to_gen_max_anisotropy(pCreateInfo->maxAnisotropy),
+ .RAddressMinFilterRoundingEnable = enable_min_filter_addr_rounding,
+ .RAddressMagFilterRoundingEnable = enable_mag_filter_addr_rounding,
+ .VAddressMinFilterRoundingEnable = enable_min_filter_addr_rounding,
+ .VAddressMagFilterRoundingEnable = enable_mag_filter_addr_rounding,
+ .UAddressMinFilterRoundingEnable = enable_min_filter_addr_rounding,
+ .UAddressMagFilterRoundingEnable = enable_mag_filter_addr_rounding,
+ .TrilinearFilterQuality = 0,
+ .NonnormalizedCoordinateEnable = pCreateInfo->unnormalizedCoordinates,
+ .TCXAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressModeU],
+ .TCYAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressModeV],
+ .TCZAddressControlMode = vk_to_gen_tex_address[pCreateInfo->addressModeW],
+ };
+
+ GENX(SAMPLER_STATE_pack)(NULL, sampler->state[p], &sampler_state);
+ }
*pSampler = anv_sampler_to_handle(sampler);