vk: Rename NUM_SHADER_STAGE to SHADER_STAGE_NUM
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 6 Jul 2015 23:43:28 +0000 (16:43 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 6 Jul 2015 23:43:28 +0000 (16:43 -0700)
This is a refactor of more than just the header but it lets us finish
reformating the shader stage enum.

include/vulkan/vulkan.h
src/vulkan/compiler.cpp
src/vulkan/device.c
src/vulkan/pipeline.c
src/vulkan/private.h

index 7c3aae9d344ef5c16b87556b9f1080793275b513..1d78177c155a3e04c2f791c617eb8ab6b05b365a 100644 (file)
@@ -544,8 +544,10 @@ typedef enum {
     VK_SHADER_STAGE_GEOMETRY = 3,
     VK_SHADER_STAGE_FRAGMENT = 4,
     VK_SHADER_STAGE_COMPUTE = 5,
-
-    VK_ENUM_RANGE(SHADER_STAGE, VERTEX, COMPUTE)
+    VK_SHADER_STAGE_BEGIN_RANGE = VK_SHADER_STAGE_VERTEX,
+    VK_SHADER_STAGE_END_RANGE = VK_SHADER_STAGE_COMPUTE,
+    VK_SHADER_STAGE_NUM = (VK_SHADER_STAGE_COMPUTE - VK_SHADER_STAGE_VERTEX + 1),
+    VK_SHADER_STAGE_MAX_ENUM = 0x7FFFFFFF
 } VkShaderStage;
 
 typedef enum {
index b220331408c218a9c91166d02d81803ae3bb16da..7ba42151c196cf6e4f2192f1c0812f1b8b881923 100644 (file)
@@ -1029,12 +1029,12 @@ anv_compiler_run(struct anv_compiler *compiler, struct anv_pipeline *pipeline)
 
    program = brw->ctx.Driver.NewShaderProgram(name);
    program->Shaders = (struct gl_shader **)
-      calloc(VK_NUM_SHADER_STAGE, sizeof(struct gl_shader *));
+      calloc(VK_SHADER_STAGE_NUM, sizeof(struct gl_shader *));
    fail_if(program == NULL || program->Shaders == NULL,
            "failed to create program\n");
 
    bool all_spirv = true;
-   for (unsigned i = 0; i < VK_NUM_SHADER_STAGE; i++) {
+   for (unsigned i = 0; i < VK_SHADER_STAGE_NUM; i++) {
       if (pipeline->shaders[i] == NULL)
          continue;
 
@@ -1050,7 +1050,7 @@ anv_compiler_run(struct anv_compiler *compiler, struct anv_pipeline *pipeline)
    }
 
    if (all_spirv) {
-      for (unsigned i = 0; i < VK_NUM_SHADER_STAGE; i++) {
+      for (unsigned i = 0; i < VK_SHADER_STAGE_NUM; i++) {
          if (pipeline->shaders[i])
             anv_compile_shader_spirv(compiler, program, pipeline, i);
       }
@@ -1060,7 +1060,7 @@ anv_compiler_run(struct anv_compiler *compiler, struct anv_pipeline *pipeline)
          program->_LinkedShaders[shader->Stage] = shader;
       }
    } else {
-      for (unsigned i = 0; i < VK_NUM_SHADER_STAGE; i++) {
+      for (unsigned i = 0; i < VK_SHADER_STAGE_NUM; i++) {
          if (pipeline->shaders[i])
             anv_compile_shader_glsl(compiler, program, pipeline, i);
       }
@@ -1157,7 +1157,7 @@ anv_compiler_run(struct anv_compiler *compiler, struct anv_pipeline *pipeline)
 void
 anv_compiler_free(struct anv_pipeline *pipeline)
 {
-   for (uint32_t stage = 0; stage < VK_NUM_SHADER_STAGE; stage++) {
+   for (uint32_t stage = 0; stage < VK_SHADER_STAGE_NUM; stage++) {
       if (pipeline->prog_data[stage]) {
          free(pipeline->prog_data[stage]->map_entries);
          ralloc_free(pipeline->prog_data[stage]->param);
index 64ef36a3041dc0cd15571a741d5beb4d276296eb..35eaad2177485c511249a72a56ba21b3df633b47 100644 (file)
@@ -1635,8 +1635,8 @@ VkResult anv_CreateDescriptorSetLayout(
 
    assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO);
 
-   uint32_t sampler_count[VK_NUM_SHADER_STAGE] = { 0, };
-   uint32_t surface_count[VK_NUM_SHADER_STAGE] = { 0, };
+   uint32_t sampler_count[VK_SHADER_STAGE_NUM] = { 0, };
+   uint32_t surface_count[VK_SHADER_STAGE_NUM] = { 0, };
    uint32_t num_dynamic_buffers = 0;
    uint32_t count = 0;
    uint32_t stages = 0;
@@ -1685,7 +1685,7 @@ VkResult anv_CreateDescriptorSetLayout(
 
    uint32_t sampler_total = 0;
    uint32_t surface_total = 0;
-   for (uint32_t s = 0; s < VK_NUM_SHADER_STAGE; s++) {
+   for (uint32_t s = 0; s < VK_SHADER_STAGE_NUM; s++) {
       sampler_total += sampler_count[s];
       surface_total += surface_count[s];
    }
@@ -1702,9 +1702,9 @@ VkResult anv_CreateDescriptorSetLayout(
    set_layout->shader_stages = stages;
 
    struct anv_descriptor_slot *p = set_layout->entries;
-   struct anv_descriptor_slot *sampler[VK_NUM_SHADER_STAGE];
-   struct anv_descriptor_slot *surface[VK_NUM_SHADER_STAGE];
-   for (uint32_t s = 0; s < VK_NUM_SHADER_STAGE; s++) {
+   struct anv_descriptor_slot *sampler[VK_SHADER_STAGE_NUM];
+   struct anv_descriptor_slot *surface[VK_SHADER_STAGE_NUM];
+   for (uint32_t s = 0; s < VK_SHADER_STAGE_NUM; s++) {
       set_layout->stage[s].surface_count = surface_count[s];
       set_layout->stage[s].surface_start = surface[s] = p;
       p += surface_count[s];
index f574038f83f072bcde9aae1be7f78ee6aa058e46..cd4294bfa081651ec64f5ae7c3bc0bc532132c82 100644 (file)
@@ -833,10 +833,10 @@ VkResult anv_CreatePipelineLayout(
 
    layout->num_sets = pCreateInfo->descriptorSetCount;
 
-   uint32_t surface_start[VK_NUM_SHADER_STAGE] = { 0, };
-   uint32_t sampler_start[VK_NUM_SHADER_STAGE] = { 0, };
+   uint32_t surface_start[VK_SHADER_STAGE_NUM] = { 0, };
+   uint32_t sampler_start[VK_SHADER_STAGE_NUM] = { 0, };
 
-   for (uint32_t s = 0; s < VK_NUM_SHADER_STAGE; s++) {
+   for (uint32_t s = 0; s < VK_SHADER_STAGE_NUM; s++) {
       layout->stage[s].surface_count = 0;
       layout->stage[s].sampler_count = 0;
    }
@@ -846,7 +846,7 @@ VkResult anv_CreatePipelineLayout(
          (struct anv_descriptor_set_layout *) pCreateInfo->pSetLayouts[i];
 
       layout->set[i].layout = set_layout;
-      for (uint32_t s = 0; s < VK_NUM_SHADER_STAGE; s++) {
+      for (uint32_t s = 0; s < VK_SHADER_STAGE_NUM; s++) {
          layout->set[i].surface_start[s] = surface_start[s];
          surface_start[s] += set_layout->stage[s].surface_count;
          layout->set[i].sampler_start[s] = sampler_start[s];
index 0f5986b8b8ab0951c80c2b8bfbc30b044874f6d6..a0ccb903224c380b9895ad63ed202c8b5040ed52 100644 (file)
@@ -592,7 +592,7 @@ struct anv_descriptor_set_layout {
       struct anv_descriptor_slot *surface_start;
       uint32_t sampler_count;
       struct anv_descriptor_slot *sampler_start;
-   } stage[VK_NUM_SHADER_STAGE];
+   } stage[VK_SHADER_STAGE_NUM];
 
    uint32_t count;
    uint32_t num_dynamic_buffers;
@@ -616,8 +616,8 @@ struct anv_descriptor_set {
 struct anv_pipeline_layout {
    struct {
       struct anv_descriptor_set_layout *layout;
-      uint32_t surface_start[VK_NUM_SHADER_STAGE];
-      uint32_t sampler_start[VK_NUM_SHADER_STAGE];
+      uint32_t surface_start[VK_SHADER_STAGE_NUM];
+      uint32_t sampler_start[VK_SHADER_STAGE_NUM];
    } set[MAX_SETS];
 
    uint32_t num_sets;
@@ -625,7 +625,7 @@ struct anv_pipeline_layout {
    struct {
       uint32_t surface_count;
       uint32_t sampler_count;
-   } stage[VK_NUM_SHADER_STAGE];
+   } stage[VK_SHADER_STAGE_NUM];
 };
 
 struct anv_buffer {
@@ -712,7 +712,7 @@ struct anv_pipeline {
    struct anv_device *                          device;
    struct anv_batch                             batch;
    uint32_t                                     batch_data[256];
-   struct anv_shader *                          shaders[VK_NUM_SHADER_STAGE];
+   struct anv_shader *                          shaders[VK_SHADER_STAGE_NUM];
    struct anv_pipeline_layout *                 layout;
    bool                                         use_repclear;
 
@@ -720,8 +720,8 @@ struct anv_pipeline {
    struct brw_wm_prog_data                      wm_prog_data;
    struct brw_gs_prog_data                      gs_prog_data;
    struct brw_cs_prog_data                      cs_prog_data;
-   struct brw_stage_prog_data *                 prog_data[VK_NUM_SHADER_STAGE];
-   uint32_t                                     scratch_start[VK_NUM_SHADER_STAGE];
+   struct brw_stage_prog_data *                 prog_data[VK_SHADER_STAGE_NUM];
+   uint32_t                                     scratch_start[VK_SHADER_STAGE_NUM];
    uint32_t                                     total_scratch;
    struct {
       uint32_t                                  vs_start;