<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Jan 11, 2019 at 9:13 AM Iago Toral Quiroga <<a href="mailto:itoral@igalia.com">itoral@igalia.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">We had defined MAX_IMAGES as 8, which we used to size the array for<br>
image push constant data. The comment there stated that this was for<br>
gen8, but anv_nir_apply_pipeline_layout runs for all gens and writes<br>
that array, asserting that we don't exceed that number of images,<br>
which imposes a limit of MAX_IMAGES on all gens.<br>
<br>
Furthermore, despite this, we are exposing up to 64 images per shader<br>
stage on all gens, gen8 included.<br>
<br>
This patch lowers the number of images we expose in gen8 to 8 and<br>
keeps 64 images for gen9+. It also sets MAX_IMAGES to 64 so we can<br>
actually use up to 64 images in shaders, and then adds an assert<br>
specific to gen8 to check that we never exceed 8.<br>
<br>
v2:<br>
- <= instead of < in the assert (Eric, Lionel)<br>
- Change the way the assertion is written (Eric)<br>
<br>
v3:<br>
- Revert the way the assertion is written to the for it had in v1,<br>
the version in v2 was not equivalent and was incorrect. (Lionel)<br>
---<br>
src/intel/vulkan/anv_device.c | 7 +++++--<br>
src/intel/vulkan/anv_nir_apply_pipeline_layout.c | 4 +++-<br>
src/intel/vulkan/anv_private.h | 4 ++--<br>
3 files changed, 10 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c<br>
index 523f1483e2..f85458b672 100644<br>
--- a/src/intel/vulkan/anv_device.c<br>
+++ b/src/intel/vulkan/anv_device.c<br>
@@ -987,9 +987,12 @@ void anv_GetPhysicalDeviceProperties(<br>
const uint32_t max_samplers = (devinfo->gen >= 8 || devinfo->is_haswell) ?<br>
128 : 16;<br>
<br>
+ const uint32_t max_images = devinfo->gen < 9 ? MAX_GEN8_IMAGES : MAX_IMAGES;<br>
+<br>
VkSampleCountFlags sample_counts =<br>
isl_device_get_sample_counts(&pdevice->isl_dev);<br>
<br>
+<br>
VkPhysicalDeviceLimits limits = {<br>
.maxImageDimension1D = (1 << 14),<br>
.maxImageDimension2D = (1 << 14),<br>
@@ -1009,7 +1012,7 @@ void anv_GetPhysicalDeviceProperties(<br>
.maxPerStageDescriptorUniformBuffers = 64,<br>
.maxPerStageDescriptorStorageBuffers = 64,<br>
.maxPerStageDescriptorSampledImages = max_samplers,<br>
- .maxPerStageDescriptorStorageImages = 64,<br>
+ .maxPerStageDescriptorStorageImages = max_images,<br>
.maxPerStageDescriptorInputAttachments = 64,<br>
.maxPerStageResources = 250,<br>
.maxDescriptorSetSamplers = 6 * max_samplers, /* number of stages * maxPerStageDescriptorSamplers */<br>
@@ -1018,7 +1021,7 @@ void anv_GetPhysicalDeviceProperties(<br>
.maxDescriptorSetStorageBuffers = 6 * 64, /* number of stages * maxPerStageDescriptorStorageBuffers */<br>
.maxDescriptorSetStorageBuffersDynamic = MAX_DYNAMIC_BUFFERS / 2,<br>
.maxDescriptorSetSampledImages = 6 * max_samplers, /* number of stages * maxPerStageDescriptorSampledImages */<br>
- .maxDescriptorSetStorageImages = 6 * 64, /* number of stages * maxPerStageDescriptorStorageImages */<br>
+ .maxDescriptorSetStorageImages = 6 * max_images, /* number of stages * maxPerStageDescriptorStorageImages */<br>
.maxDescriptorSetInputAttachments = 256,<br>
.maxVertexInputAttributes = MAX_VBS,<br>
.maxVertexInputBindings = MAX_VBS,<br>
diff --git a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c<br>
index b3daf702bc..ae5c19578c 100644<br>
--- a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c<br>
+++ b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c<br>
@@ -529,7 +529,9 @@ anv_nir_apply_pipeline_layout(const struct anv_physical_device *pdevice,<br>
}<br>
<br>
if (map->image_count > 0) {<br>
- assert(map->image_count <= MAX_IMAGES);<br>
+ assert(map->image_count <= MAX_IMAGES &&<br>
+ (pdevice->compiler->devinfo->gen > 8 ||<br>
+ map->image_count <= MAX_GEN8_IMAGES));<br>
assert(shader->num_uniforms == prog_data->nr_params * 4);<br>
state.first_image_uniform = shader->num_uniforms;<br>
uint32_t *param = brw_stage_prog_data_add_params(prog_data,<br>
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h<br>
index 770254e93e..9ddd41b1fa 100644<br>
--- a/src/intel/vulkan/anv_private.h<br>
+++ b/src/intel/vulkan/anv_private.h<br>
@@ -157,7 +157,8 @@ struct gen_l3_config;<br>
#define MAX_SCISSORS 16<br>
#define MAX_PUSH_CONSTANTS_SIZE 128<br>
#define MAX_DYNAMIC_BUFFERS 16<br>
-#define MAX_IMAGES 8<br>
+#define MAX_IMAGES 64<br>
+#define MAX_GEN8_IMAGES 8<br>
#define MAX_PUSH_DESCRIPTORS 32 /* Minimum requirement */<br>
<br>
/* The kernel relocation API has a limitation of a 32-bit delta value<br>
@@ -1882,7 +1883,6 @@ struct anv_push_constants {<br>
/* Used for vkCmdDispatchBase */<br>
uint32_t base_work_group_id[3];<br>
<br>
- /* Image data for image_load_store on pre-SKL */<br>
struct brw_image_param images[MAX_IMAGES];<br></blockquote><div><br></div><div>Why are we dropping the comment and why isn't this MAX_GEN8_IMAGES? The push params shouldn't be needed by gen9+ hence our ability to increase it to 64 without blowing out our push constant space.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
};<br>
<br>
-- <br>
2.17.1<br>
<br>
</blockquote></div></div>