<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 15, 2017 at 7:11 AM, Lionel Landwerlin <span dir="ltr"><<a href="mailto:lionel.g.landwerlin@intel.com" target="_blank">lionel.g.landwerlin@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Lionel Landwerlin <<a href="mailto:lionel.g.landwerlin@intel.com">lionel.g.landwerlin@intel.com</a><wbr>><br>
---<br>
src/intel/vulkan/anv_<wbr>descriptor_set.c | 107 +++++++++++++++++------<br>
src/intel/vulkan/anv_nir_<wbr>apply_pipeline_layout.c | 44 +++++-----<br>
src/intel/vulkan/anv_private.h | 24 ++++-<br>
src/intel/vulkan/genX_cmd_<wbr>buffer.c | 14 ++-<br>
src/intel/vulkan/genX_state.c | 81 +++++++++--------<br>
5 files changed, 178 insertions(+), 92 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_<wbr>descriptor_set.c b/src/intel/vulkan/anv_<wbr>descriptor_set.c<br>
index 91387c065e4..4e29310f5fa 100644<br>
--- a/src/intel/vulkan/anv_<wbr>descriptor_set.c<br>
+++ b/src/intel/vulkan/anv_<wbr>descriptor_set.c<br>
@@ -35,6 +35,21 @@<br>
* Descriptor set layouts.<br>
*/<br>
<br>
+static uint32_t<br>
+layout_binding_get_<wbr>descriptor_count(const VkDescriptorSetLayoutBinding *binding)<br>
+{<br>
+ if (binding->pImmutableSamplers == NULL)<br>
+ return binding->descriptorCount;<br>
+<br>
+ uint32_t immutable_sampler_count = 0;<br>
+ for (uint32_t i = 0; i < binding->descriptorCount; i++) {<br>
+ ANV_FROM_HANDLE(anv_sampler, sampler, binding->pImmutableSamplers[i]<wbr>);<br>
+ immutable_sampler_count += sampler->nb_planes;<br>
+ }<br>
+<br>
+ return immutable_sampler_count;<br>
+}<br>
+<br>
VkResult anv_CreateDescriptorSetLayout(<br>
VkDevice _device,<br>
const VkDescriptorSetLayoutCreateInf<wbr>o* pCreateInfo,<br>
@@ -49,13 +64,13 @@ VkResult anv_CreateDescriptorSetLayout(<br>
uint32_t immutable_sampler_count = 0;<br>
for (uint32_t j = 0; j < pCreateInfo->bindingCount; j++) {<br>
max_binding = MAX2(max_binding, pCreateInfo->pBindings[j].<wbr>binding);<br>
- if (pCreateInfo->pBindings[j].<wbr>pImmutableSamplers)<br>
- immutable_sampler_count += pCreateInfo->pBindings[j].<wbr>descriptorCount;<br>
+ immutable_sampler_count +=<br>
+ layout_binding_get_descriptor_<wbr>count(&pCreateInfo->pBindings[<wbr>j]);<br>
}<br>
<br>
struct anv_descriptor_set_layout *set_layout;<br>
struct anv_descriptor_set_binding_<wbr>layout *bindings;<br>
- struct anv_sampler **samplers;<br>
+ struct anv_descriptor_set_immutable_<wbr>sampler *samplers;<br>
<br>
ANV_MULTIALLOC(ma);<br>
anv_multialloc_add(&ma, &set_layout, 1);<br>
@@ -74,6 +89,7 @@ VkResult anv_CreateDescriptorSetLayout(<br>
memset(&set_layout->binding[b]<wbr>, -1, sizeof(set_layout->binding[b])<wbr>);<br>
<br>
set_layout->binding[b].array_<wbr>size = 0;<br>
+ set_layout->binding[b].<wbr>descriptor_size = 0;<br>
set_layout->binding[b].<wbr>immutable_samplers = NULL;<br>
}<br>
<br>
@@ -108,17 +124,20 @@ VkResult anv_CreateDescriptorSetLayout(<br>
set_layout->binding[b].type = binding->descriptorType;<br>
#endif<br>
set_layout->binding[b].array_<wbr>size = binding->descriptorCount;<br>
+ set_layout->binding[b].<wbr>descriptor_size =<br>
+ layout_binding_get_descriptor_<wbr>count(binding);<br>
set_layout->binding[b].<wbr>descriptor_index = set_layout->size;<br>
- set_layout->size += binding->descriptorCount;<br>
+ set_layout->size += set_layout->binding[b].<wbr>descriptor_size;<br>
<br>
switch (binding->descriptorType) {<br>
case VK_DESCRIPTOR_TYPE_SAMPLER:<br>
- case VK_DESCRIPTOR_TYPE_COMBINED_<wbr>IMAGE_SAMPLER:<br>
+ case VK_DESCRIPTOR_TYPE_COMBINED_<wbr>IMAGE_SAMPLER: {<br>
anv_foreach_stage(s, binding->stageFlags) {<br>
set_layout->binding[b].stage[<wbr>s].sampler_index = sampler_count[s];<br>
- sampler_count[s] += binding->descriptorCount;<br>
+ sampler_count[s] += set_layout->binding[b].<wbr>descriptor_size;<br>
}<br>
break;<br>
+ }<br>
default:<br>
break;<br>
}<br>
@@ -140,7 +159,7 @@ VkResult anv_CreateDescriptorSetLayout(<br>
case VK_DESCRIPTOR_TYPE_INPUT_<wbr>ATTACHMENT:<br>
anv_foreach_stage(s, binding->stageFlags) {<br>
set_layout->binding[b].stage[<wbr>s].surface_index = surface_count[s];<br>
- surface_count[s] += binding->descriptorCount;<br>
+ surface_count[s] += set_layout->binding[b].<wbr>descriptor_size;<br>
}<br>
break;<br>
default:<br>
@@ -151,7 +170,7 @@ VkResult anv_CreateDescriptorSetLayout(<br>
case VK_DESCRIPTOR_TYPE_UNIFORM_<wbr>BUFFER_DYNAMIC:<br>
case VK_DESCRIPTOR_TYPE_STORAGE_<wbr>BUFFER_DYNAMIC:<br>
set_layout->binding[b].<wbr>dynamic_offset_index = dynamic_offset_count;<br>
- dynamic_offset_count += binding->descriptorCount;<br>
+ dynamic_offset_count += set_layout->binding[b].<wbr>descriptor_size;<br></blockquote><div><br></div><div>Are you sure about adjusting dynamic_offset_count here?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
break;<br>
default:<br>
break;<br>
@@ -162,7 +181,7 @@ VkResult anv_CreateDescriptorSetLayout(<br>
case VK_DESCRIPTOR_TYPE_STORAGE_<wbr>TEXEL_BUFFER:<br>
anv_foreach_stage(s, binding->stageFlags) {<br>
set_layout->binding[b].stage[<wbr>s].image_index = image_count[s];<br>
- image_count[s] += binding->descriptorCount;<br>
+ image_count[s] += set_layout->binding[b].<wbr>descriptor_size;<br>
}<br>
break;<br>
default:<br>
@@ -171,11 +190,18 @@ VkResult anv_CreateDescriptorSetLayout(<br>
<br>
if (binding->pImmutableSamplers) {<br>
set_layout->binding[b].<wbr>immutable_samplers = samplers;<br>
- samplers += binding->descriptorCount;<br>
<br>
- for (uint32_t i = 0; i < binding->descriptorCount; i++)<br>
- set_layout->binding[b].<wbr>immutable_samplers[i] =<br>
- anv_sampler_from_handle(<wbr>binding->pImmutableSamplers[i]<wbr>);<br>
+ uint32_t sampler_offset = 0;<br>
+ for (uint32_t i = 0; i < binding->descriptorCount; i++) {<br>
+ ANV_FROM_HANDLE(anv_sampler, sampler, binding->pImmutableSamplers[i]<wbr>);<br>
+<br>
+ set_layout->binding[b].<wbr>immutable_samplers[i].sampler = sampler;<br>
+ set_layout->binding[b].<wbr>immutable_samplers[i].<wbr>descriptor_index_offset =<br>
+ sampler_offset;<br>
+ sampler_offset += sampler->nb_planes;<br>
+ }<br>
+<br>
+ samplers += sampler_offset;<br>
} else {<br>
set_layout->binding[b].<wbr>immutable_samplers = NULL;<br>
}<br>
@@ -250,7 +276,7 @@ VkResult anv_CreatePipelineLayout(<br>
if (set_layout->binding[b].<wbr>dynamic_offset_index < 0)<br>
continue;<br>
<br>
- dynamic_offset_count += set_layout->binding[b].array_<wbr>size;<br>
+ dynamic_offset_count += set_layout->binding[b].<wbr>descriptor_size;<br>
for (gl_shader_stage s = 0; s < MESA_SHADER_STAGES; s++) {<br>
if (set_layout->binding[b].stage[<wbr>s].surface_index >= 0)<br>
layout->stage[s].has_dynamic_<wbr>offsets = true;<br>
@@ -318,11 +344,24 @@ VkResult anv_CreateDescriptorPool(<br>
uint32_t buffer_count = 0;<br>
for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; i++) {<br>
switch (pCreateInfo->pPoolSizes[i].<wbr>type) {<br>
+ case VK_DESCRIPTOR_TYPE_SAMPLER:<br>
+ case VK_DESCRIPTOR_TYPE_COMBINED_<wbr>IMAGE_SAMPLER:<br>
+ /* We have to account that some descriptor layouts might have<br>
+ * multiplanar images (atm up to 3 through the conversion<br>
+ * VK_KHR_sampler_ycbcr_<wbr>conversion extension). Therefor take the<br>
+ * maximum amount of space that can be occupied by a single of those<br>
+ * entries.<br>
+ */<br>
+ descriptor_count += 3 * pCreateInfo->pPoolSizes[i].<wbr>descriptorCount;<br></blockquote><div><br></div><div>I'm not quite sure how I expected you to solve the multi-descriptor problem but it wasn't like this. :) An alternate solution would be to keep each image_view and sampler a single descriptor in the descriptor set and expand it out to multiple descriptors as-needed in anv_nir_apply_pipeline_layout by adding a "plane" entry to anv_pipeline_binding. I'm honestly not sure which one would work out better in the end.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ break;<br>
+<br>
case VK_DESCRIPTOR_TYPE_UNIFORM_<wbr>BUFFER:<br>
case VK_DESCRIPTOR_TYPE_STORAGE_<wbr>BUFFER:<br>
case VK_DESCRIPTOR_TYPE_UNIFORM_<wbr>BUFFER_DYNAMIC:<br>
case VK_DESCRIPTOR_TYPE_STORAGE_<wbr>BUFFER_DYNAMIC:<br>
buffer_count += pCreateInfo->pPoolSizes[i].<wbr>descriptorCount;<br>
+ /* Fallthrough */<br>
+<br>
default:<br>
descriptor_count += pCreateInfo->pPoolSizes[i].<wbr>descriptorCount;<br>
break;<br>
@@ -461,13 +500,18 @@ anv_descriptor_set_create(<wbr>struct anv_device *device,<br>
* set has an immutable sampler, UpdateDescriptorSets may never<br>
* touch it, so we need to make sure it's 100% valid now.<br>
*/<br>
- desc[i] = (struct anv_descriptor) {<br>
- .type = VK_DESCRIPTOR_TYPE_SAMPLER,<br>
- .sampler = layout->binding[b].immutable_<wbr>samplers[i],<br>
- };<br>
+ struct anv_descriptor_set_immutable_<wbr>sampler *sampler =<br>
+ &layout->binding[b].immutable_<wbr>samplers[i];<br>
+ for (uint32_t p = 0; p < sampler->sampler->nb_planes; p++) {<br>
+ desc[sampler->descriptor_<wbr>index_offset + p] = (struct anv_descriptor) {<br>
+ .type = VK_DESCRIPTOR_TYPE_SAMPLER,<br>
+ .sampler = sampler->sampler,<br>
+ .plane = p,<br>
+ };<br>
+ }<br>
}<br>
}<br>
- desc += layout->binding[b].array_size;<br>
+ desc += layout->binding[b].descriptor_<wbr>size;<br>
}<br>
<br>
/* Allocate surface state for the buffer views. */<br>
@@ -579,8 +623,13 @@ anv_descriptor_set_write_<wbr>image_view(struct anv_descriptor_set *set,<br>
{<br>
const struct anv_descriptor_set_binding_<wbr>layout *bind_layout =<br>
&set->layout->binding[binding]<wbr>;<br>
+ const struct anv_descriptor_set_immutable_<wbr>sampler *immutable_sampler =<br>
+ bind_layout->immutable_<wbr>samplers ?<br>
+ &bind_layout->immutable_<wbr>samplers[element] : NULL;<br>
+ uint32_t descriptor_index_offset =<br>
+ immutable_sampler ? immutable_sampler->descriptor_<wbr>index_offset : element;<br>
struct anv_descriptor *desc =<br>
- &set->descriptors[bind_layout-<wbr>>descriptor_index + element];<br>
+ &set->descriptors[bind_layout-<wbr>>descriptor_index + descriptor_index_offset];<br>
struct anv_image_view *image_view = NULL;<br>
struct anv_sampler *sampler = NULL;<br>
<br>
@@ -610,15 +659,19 @@ anv_descriptor_set_write_<wbr>image_view(struct anv_descriptor_set *set,<br>
* it.<br>
*/<br>
sampler = bind_layout->immutable_<wbr>samplers ?<br>
- bind_layout->immutable_<wbr>samplers[element] :<br>
+ bind_layout->immutable_<wbr>samplers[element].sampler :<br>
sampler;<br>
<br>
- *desc = (struct anv_descriptor) {<br>
- .type = type,<br>
- .layout = info->imageLayout,<br>
- .image_view = image_view,<br>
- .sampler = sampler,<br>
- };<br>
+ uint32_t nb_planes = sampler != NULL ? sampler->nb_planes : 1;<br>
+ for (uint32_t p = 0; p < nb_planes; p++) {<br>
+ desc[p] = (struct anv_descriptor) {<br>
+ .type = type,<br>
+ .layout = info->imageLayout,<br>
+ .image_view = image_view,<br>
+ .sampler = sampler,<br>
+ .plane = p,<br>
+ };<br>
+ }<br>
}<br>
<br>
void<br>
diff --git a/src/intel/vulkan/anv_nir_<wbr>apply_pipeline_layout.c b/src/intel/vulkan/anv_nir_<wbr>apply_pipeline_layout.c<br>
index 67bcf5e29ef..83d4c4ea30d 100644<br>
--- a/src/intel/vulkan/anv_nir_<wbr>apply_pipeline_layout.c<br>
+++ b/src/intel/vulkan/anv_nir_<wbr>apply_pipeline_layout.c<br>
@@ -130,7 +130,7 @@ lower_res_index_intrinsic(nir_<wbr>intrinsic_instr *intrin,<br>
<br>
static void<br>
lower_tex_deref(nir_tex_instr *tex, nir_deref_var *deref,<br>
- unsigned *const_index, unsigned array_size,<br>
+ unsigned *const_index, unsigned descriptor_size,<br>
nir_tex_src_type src_type,<br>
struct apply_pipeline_layout_state *state)<br>
{<br>
@@ -146,7 +146,7 @@ lower_tex_deref(nir_tex_instr *tex, nir_deref_var *deref,<br>
nir_ssa_for_src(b, deref_array->indirect, 1));<br>
<br>
if (state->add_bounds_checks)<br>
- index = nir_umin(b, index, nir_imm_int(b, array_size - 1));<br>
+ index = nir_umin(b, index, nir_imm_int(b, descriptor_size - 1));<br>
<br>
nir_tex_src *new_srcs = rzalloc_array(tex, nir_tex_src,<br>
tex->num_srcs + 1);<br>
@@ -167,7 +167,7 @@ lower_tex_deref(nir_tex_instr *tex, nir_deref_var *deref,<br>
nir_src_for_ssa(index));<br>
tex->num_srcs++;<br>
} else {<br>
- *const_index += MIN2(deref_array->base_offset, array_size - 1);<br>
+ *const_index += MIN2(deref_array->base_offset, descriptor_size - 1);<br>
}<br>
}<br>
}<br>
@@ -196,19 +196,18 @@ lower_tex(nir_tex_instr *tex, struct apply_pipeline_layout_state *state)<br>
<br>
unsigned set = tex->texture->var->data.<wbr>descriptor_set;<br>
unsigned binding = tex->texture->var->data.<wbr>binding;<br>
- unsigned array_size =<br>
- state->layout->set[set].<wbr>layout->binding[binding].<wbr>array_size;<br>
+ unsigned descriptor_size =<br>
+ state->layout->set[set].<wbr>layout->binding[binding].<wbr>descriptor_size;<br>
tex->texture_index = state->set[set].surface_<wbr>offsets[binding];<br>
- lower_tex_deref(tex, tex->texture, &tex->texture_index, array_size,<br>
+ lower_tex_deref(tex, tex->texture, &tex->texture_index, descriptor_size,<br>
nir_tex_src_texture_offset, state);<br>
<br>
if (tex->sampler) {<br>
unsigned set = tex->sampler->var->data.<wbr>descriptor_set;<br>
unsigned binding = tex->sampler->var->data.<wbr>binding;<br>
- unsigned array_size =<br>
- state->layout->set[set].<wbr>layout->binding[binding].<wbr>array_size;<br>
- tex->sampler_index = state->set[set].sampler_<wbr>offsets[binding];<br>
- lower_tex_deref(tex, tex->sampler, &tex->sampler_index, array_size,<br>
+ unsigned descriptor_size =<br>
+ state->layout->set[set].<wbr>layout->binding[binding].<wbr>descriptor_size;<br>
+ lower_tex_deref(tex, tex->sampler, &tex->sampler_index, descriptor_size,<br>
nir_tex_src_sampler_offset, state);<br>
}<br>
<br>
@@ -300,9 +299,9 @@ anv_nir_apply_pipeline_layout(<wbr>struct anv_pipeline *pipeline,<br>
BITSET_FOREACH_SET(b, _tmp, state.set[set].used,<br>
set_layout->binding_count) {<br>
if (set_layout->binding[b].stage[<wbr>shader->stage].surface_index >= 0)<br>
- map->surface_count += set_layout->binding[b].array_<wbr>size;<br>
+ map->surface_count += set_layout->binding[b].<wbr>descriptor_size;<br>
if (set_layout->binding[b].stage[<wbr>shader->stage].sampler_index >= 0)<br>
- map->sampler_count += set_layout->binding[b].array_<wbr>size;<br>
+ map->sampler_count += set_layout->binding[b].<wbr>descriptor_size;<br>
if (set_layout->binding[b].stage[<wbr>shader->stage].image_index >= 0)<br>
map->image_count += set_layout->binding[b].array_<wbr>size;<br>
}<br>
@@ -317,31 +316,34 @@ anv_nir_apply_pipeline_layout(<wbr>struct anv_pipeline *pipeline,<br>
BITSET_WORD b, _tmp;<br>
BITSET_FOREACH_SET(b, _tmp, state.set[set].used,<br>
set_layout->binding_count) {<br>
- unsigned array_size = set_layout->binding[b].array_<wbr>size;<br>
+ struct anv_descriptor_set_binding_<wbr>layout *binding =<br>
+ &set_layout->binding[b];<br>
+ /* unsigned array_size = set_layout->binding[b].array_<wbr>size; */<br>
+ /* unsigned descriptor_size = set_layout->binding[b].<wbr>descriptor_size; */<br>
<br>
- if (set_layout->binding[b].stage[<wbr>shader->stage].surface_index >= 0) {<br>
+ if (binding->stage[shader->stage]<wbr>.surface_index >= 0) {<br>
state.set[set].surface_<wbr>offsets[b] = surface;<br>
- for (unsigned i = 0; i < array_size; i++) {<br>
+ for (unsigned i = 0; i < binding->descriptor_size; i++) {<br>
map->surface_to_descriptor[<wbr>surface + i].set = set;<br>
map->surface_to_descriptor[<wbr>surface + i].binding = b;<br>
map->surface_to_descriptor[<wbr>surface + i].index = i;<br>
}<br>
- surface += array_size;<br>
+ surface += binding->descriptor_size;<br>
}<br>
<br>
- if (set_layout->binding[b].stage[<wbr>shader->stage].sampler_index >= 0) {<br>
+ if (binding->stage[shader->stage]<wbr>.sampler_index >= 0) {<br>
state.set[set].sampler_<wbr>offsets[b] = sampler;<br>
- for (unsigned i = 0; i < array_size; i++) {<br>
+ for (unsigned i = 0; i < binding->descriptor_size; i++) {<br>
map->sampler_to_descriptor[<wbr>sampler + i].set = set;<br>
map->sampler_to_descriptor[<wbr>sampler + i].binding = b;<br>
map->sampler_to_descriptor[<wbr>sampler + i].index = i;<br>
}<br>
- sampler += array_size;<br>
+ sampler += binding->descriptor_size;<br>
}<br>
<br>
- if (set_layout->binding[b].stage[<wbr>shader->stage].image_index >= 0) {<br>
+ if (binding->stage[shader->stage]<wbr>.image_index >= 0) {<br>
state.set[set].image_offsets[<wbr>b] = image;<br>
- image += array_size;<br>
+ image += binding->descriptor_size;<br>
}<br>
}<br>
}<br>
diff --git a/src/intel/vulkan/anv_<wbr>private.h b/src/intel/vulkan/anv_<wbr>private.h<br>
index a4b263cea5e..41f01192aa6 100644<br>
--- a/src/intel/vulkan/anv_<wbr>private.h<br>
+++ b/src/intel/vulkan/anv_<wbr>private.h<br>
@@ -1168,6 +1168,18 @@ struct anv_vue_header {<br>
float PointWidth;<br>
};<br>
<br>
+struct anv_descriptor_set_immutable_<wbr>sampler {<br>
+ /* Immutable sampler */<br>
+ struct anv_sampler *sampler;<br>
+<br>
+ /* Offset to add to<br>
+ * anv_descriptor_set_binding_<wbr>layout.stage[s].sampler_index or<br>
+ * anv_descriptor_set_binding_<wbr>layout.descriptor_index to compute the offset<br>
+ * in the descriptor table.<br>
+ */<br>
+ uint16_t descriptor_index_offset;<br>
+};<br>
+<br>
struct anv_descriptor_set_binding_<wbr>layout {<br>
#ifndef NDEBUG<br>
/* The type of the descriptors in this binding */<br>
@@ -1177,6 +1189,9 @@ struct anv_descriptor_set_binding_<wbr>layout {<br>
/* Number of array elements in this binding */<br>
uint16_t array_size;<br>
<br>
+ /* Number of descriptors used in this binding */<br>
+ uint16_t descriptor_size;<br>
+<br>
/* Index into the flattend descriptor set */<br>
uint16_t descriptor_index;<br>
<br>
@@ -1198,7 +1213,7 @@ struct anv_descriptor_set_binding_<wbr>layout {<br>
} stage[MESA_SHADER_STAGES];<br>
<br>
/* Immutable samplers (or NULL if no immutable samplers) */<br>
- struct anv_sampler **immutable_samplers;<br>
+ struct anv_descriptor_set_immutable_<wbr>sampler *immutable_samplers;<br>
};<br>
<br>
struct anv_descriptor_set_layout {<br>
@@ -1229,6 +1244,10 @@ struct anv_descriptor {<br>
VkImageLayout layout;<br>
struct anv_image_view *image_view;<br>
struct anv_sampler *sampler;<br>
+<br>
+ /* Used to dertermine what plane of the sampler/image we need<br>
+ * program. */<br>
+ uint32_t plane;<br>
};<br>
<br>
struct {<br>
@@ -2504,7 +2523,8 @@ void anv_fill_buffer_surface_state(<wbr>struct anv_device *device,<br>
uint32_t stride);<br>
<br>
struct anv_sampler {<br>
- uint32_t state[4];<br>
+ uint32_t state[3][4];<br>
+ uint8_t nb_planes;<br>
};<br>
<br>
struct anv_framebuffer {<br>
diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
index a16f67b108c..bea73dfb504 100644<br>
--- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
+++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
@@ -1736,7 +1736,8 @@ emit_samplers(struct anv_cmd_buffer *cmd_buffer,<br>
if (state->map == NULL)<br>
return VK_ERROR_OUT_OF_DEVICE_MEMORY;<br>
<br>
- for (uint32_t s = 0; s < map->sampler_count; s++) {<br>
+ uint32_t s = 0;<br>
+ while (s < map->sampler_count) {<br>
struct anv_pipeline_binding *binding = &map->sampler_to_descriptor[s]<wbr>;<br>
struct anv_descriptor_set *set =<br>
cmd_buffer->state.descriptors[<wbr>binding->set];<br>
@@ -1744,19 +1745,24 @@ emit_samplers(struct anv_cmd_buffer *cmd_buffer,<br>
struct anv_descriptor *desc = &set->descriptors[offset + binding->index];<br>
<br>
if (desc->type != VK_DESCRIPTOR_TYPE_SAMPLER &&<br>
- desc->type != VK_DESCRIPTOR_TYPE_COMBINED_<wbr>IMAGE_SAMPLER)<br>
+ desc->type != VK_DESCRIPTOR_TYPE_COMBINED_<wbr>IMAGE_SAMPLER) {<br>
+ s += 1;<br>
continue;<br>
+ }<br>
<br>
struct anv_sampler *sampler = desc->sampler;<br>
<br>
/* This can happen if we have an unfilled slot since TYPE_SAMPLER<br>
* happens to be zero.<br>
*/<br>
- if (sampler == NULL)<br>
+ if (sampler == NULL) {<br>
+ s += 1;<br>
continue;<br>
+ }<br>
<br>
memcpy(state->map + (s * 16),<br>
- sampler->state, sizeof(sampler->state));<br>
+ sampler->state, sampler->nb_planes * sizeof(sampler->state[0]));<br>
+ s += sampler->nb_planes;<br>
}<br>
<br>
anv_state_flush(cmd_buffer-><wbr>device, *state);<br>
diff --git a/src/intel/vulkan/genX_state.<wbr>c b/src/intel/vulkan/genX_state.<wbr>c<br>
index d016aff4a54..91e180bc7e4 100644<br>
--- a/src/intel/vulkan/genX_state.<wbr>c<br>
+++ b/src/intel/vulkan/genX_state.<wbr>c<br>
@@ -171,6 +171,9 @@ VkResult genX(CreateSampler)(<br>
if (!sampler)<br>
return vk_error(VK_ERROR_OUT_OF_HOST_<wbr>MEMORY);<br>
<br>
+ memset(sampler, 0, sizeof(*sampler));<br></blockquote><div><br></div><div>We have vk_zalloc for this.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ sampler->nb_planes = 1;<br>
+<br>
uint32_t border_color_offset = device->border_colors.offset +<br>
pCreateInfo->borderColor * 64;<br>
<br>
@@ -179,55 +182,57 @@ VkResult genX(CreateSampler)(<br>
bool enable_mag_filter_addr_<wbr>rounding =<br>
pCreateInfo->magFilter != VK_FILTER_NEAREST;<br>
<br>
- struct GENX(SAMPLER_STATE) sampler_state = {<br>
- .SamplerDisable = false,<br>
- .TextureBorderColorMode = DX10OGL,<br>
+ for (unsigned p = 0; p < sampler->nb_planes; p++) {<br></blockquote><div><br></div><div>What's the difference between the N samplers you're creating here. I don't see any from my immediate reading of the diff but mayabe that's just because there's too much churn or maybe it's just in a different patch...<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ struct GENX(SAMPLER_STATE) sampler_state = {<br>
+ .SamplerDisable = false,<br>
+ .TextureBorderColorMode = DX10OGL,<br>
<br>
#if GEN_GEN >= 8<br>
- .LODPreClampMode = CLAMP_MODE_OGL,<br>
+ .LODPreClampMode = CLAMP_MODE_OGL,<br>
#else<br>
- .LODPreClampEnable = CLAMP_ENABLE_OGL,<br>
+ .LODPreClampEnable = CLAMP_ENABLE_OGL,<br>
#endif<br>
<br>
#if GEN_GEN == 8<br>
- .BaseMipLevel = 0.0,<br>
+ .BaseMipLevel = 0.0,<br>
#endif<br>
- .MipModeFilter = vk_to_gen_mipmap_mode[<wbr>pCreateInfo->mipmapMode],<br>
- .MagModeFilter = vk_to_gen_tex_filter(<wbr>pCreateInfo->magFilter,<br>
- pCreateInfo->anisotropyEnable)<wbr>,<br>
- .MinModeFilter = vk_to_gen_tex_filter(<wbr>pCreateInfo->minFilter,<br>
- pCreateInfo->anisotropyEnable)<wbr>,<br>
- .TextureLODBias = anv_clamp_f(pCreateInfo-><wbr>mipLodBias, -16, 15.996),<br>
- .AnisotropicAlgorithm = EWAApproximation,<br>
- .MinLOD = anv_clamp_f(pCreateInfo-><wbr>minLod, 0, 14),<br>
- .MaxLOD = anv_clamp_f(pCreateInfo-><wbr>maxLod, 0, 14),<br>
- .ChromaKeyEnable = 0,<br>
- .ChromaKeyIndex = 0,<br>
- .ChromaKeyMode = 0,<br>
- .ShadowFunction = vk_to_gen_shadow_compare_op[<wbr>pCreateInfo->compareOp],<br>
- .CubeSurfaceControlMode = OVERRIDE,<br>
-<br>
- .BorderColorPointer = border_color_offset,<br>
+ .MipModeFilter = vk_to_gen_mipmap_mode[<wbr>pCreateInfo->mipmapMode],<br>
+ .MagModeFilter = vk_to_gen_tex_filter(<wbr>pCreateInfo->magFilter,<br>
+ pCreateInfo->anisotropyEnable)<wbr>,<br>
+ .MinModeFilter = vk_to_gen_tex_filter(<wbr>pCreateInfo->minFilter,<br>
+ pCreateInfo->anisotropyEnable)<wbr>,<br>
+ .TextureLODBias = anv_clamp_f(pCreateInfo-><wbr>mipLodBias, -16, 15.996),<br>
+ .AnisotropicAlgorithm = EWAApproximation,<br>
+ .MinLOD = anv_clamp_f(pCreateInfo-><wbr>minLod, 0, 14),<br>
+ .MaxLOD = anv_clamp_f(pCreateInfo-><wbr>maxLod, 0, 14),<br>
+ .ChromaKeyEnable = 0,<br>
+ .ChromaKeyIndex = 0,<br>
+ .ChromaKeyMode = 0,<br>
+ .ShadowFunction = vk_to_gen_shadow_compare_op[<wbr>pCreateInfo->compareOp],<br>
+ .CubeSurfaceControlMode = OVERRIDE,<br>
+<br>
+ .BorderColorPointer = border_color_offset,<br>
<br>
#if GEN_GEN >= 8<br>
- .LODClampMagnificationMode = MIPNONE,<br>
+ .LODClampMagnificationMode = MIPNONE,<br>
#endif<br>
<br>
- .MaximumAnisotropy = vk_to_gen_max_anisotropy(<wbr>pCreateInfo->maxAnisotropy),<br>
- .<wbr>RAddressMinFilterRoundingEnabl<wbr>e = enable_min_filter_addr_<wbr>rounding,<br>
- .<wbr>RAddressMagFilterRoundingEnabl<wbr>e = enable_mag_filter_addr_<wbr>rounding,<br>
- .<wbr>VAddressMinFilterRoundingEnabl<wbr>e = enable_min_filter_addr_<wbr>rounding,<br>
- .<wbr>VAddressMagFilterRoundingEnabl<wbr>e = enable_mag_filter_addr_<wbr>rounding,<br>
- .<wbr>UAddressMinFilterRoundingEnabl<wbr>e = enable_min_filter_addr_<wbr>rounding,<br>
- .<wbr>UAddressMagFilterRoundingEnabl<wbr>e = enable_mag_filter_addr_<wbr>rounding,<br>
- .TrilinearFilterQuality = 0,<br>
- .NonnormalizedCoordinateEnable = pCreateInfo-><wbr>unnormalizedCoordinates,<br>
- .TCXAddressControlMode = vk_to_gen_tex_address[<wbr>pCreateInfo->addressModeU],<br>
- .TCYAddressControlMode = vk_to_gen_tex_address[<wbr>pCreateInfo->addressModeV],<br>
- .TCZAddressControlMode = vk_to_gen_tex_address[<wbr>pCreateInfo->addressModeW],<br>
- };<br>
-<br>
- GENX(SAMPLER_STATE_pack)(NULL, sampler->state, &sampler_state);<br>
+ .MaximumAnisotropy = vk_to_gen_max_anisotropy(<wbr>pCreateInfo->maxAnisotropy),<br>
+ .<wbr>RAddressMinFilterRoundingEnabl<wbr>e = enable_min_filter_addr_<wbr>rounding,<br>
+ .<wbr>RAddressMagFilterRoundingEnabl<wbr>e = enable_mag_filter_addr_<wbr>rounding,<br>
+ .<wbr>VAddressMinFilterRoundingEnabl<wbr>e = enable_min_filter_addr_<wbr>rounding,<br>
+ .<wbr>VAddressMagFilterRoundingEnabl<wbr>e = enable_mag_filter_addr_<wbr>rounding,<br>
+ .<wbr>UAddressMinFilterRoundingEnabl<wbr>e = enable_min_filter_addr_<wbr>rounding,<br>
+ .<wbr>UAddressMagFilterRoundingEnabl<wbr>e = enable_mag_filter_addr_<wbr>rounding,<br>
+ .TrilinearFilterQuality = 0,<br>
+ .NonnormalizedCoordinateEnable = pCreateInfo-><wbr>unnormalizedCoordinates,<br>
+ .TCXAddressControlMode = vk_to_gen_tex_address[<wbr>pCreateInfo->addressModeU],<br>
+ .TCYAddressControlMode = vk_to_gen_tex_address[<wbr>pCreateInfo->addressModeV],<br>
+ .TCZAddressControlMode = vk_to_gen_tex_address[<wbr>pCreateInfo->addressModeW],<br>
+ };<br>
+<br>
+ GENX(SAMPLER_STATE_pack)(NULL, sampler->state[p], &sampler_state);<br>
+ }<br>
<br>
*pSampler = anv_sampler_to_handle(sampler)<wbr>;<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.14.1<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>