summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-12-02 14:35:07 -0800
committerJason Ekstrand <[email protected]>2015-12-03 13:43:54 -0800
commite10dc002e9544500a2247e49a132e18f994f34ee (patch)
treec60271cafa56ee1223a200dbec20bc74b41bd5ac /src
parente6ab06ae7f084ba0df4c4274e5de010a3a751cc2 (diff)
vk/0.210.0: Remove VkShader
Diffstat (limited to 'src')
-rw-r--r--src/vulkan/anv_meta.c49
-rw-r--r--src/vulkan/anv_meta_clear.c27
-rw-r--r--src/vulkan/anv_pipeline.c99
-rw-r--r--src/vulkan/anv_private.h9
-rw-r--r--src/vulkan/gen8_pipeline.c5
5 files changed, 56 insertions, 133 deletions
diff --git a/src/vulkan/anv_meta.c b/src/vulkan/anv_meta.c
index a5fb782eab8..84f828eb4cf 100644
--- a/src/vulkan/anv_meta.c
+++ b/src/vulkan/anv_meta.c
@@ -224,42 +224,18 @@ anv_device_init_meta_blit_state(struct anv_device *device)
* to provide GLSL source for the vertex shader so that the compiler
* does not dead-code our inputs.
*/
- struct anv_shader_module vsm = {
+ struct anv_shader_module vs = {
.nir = build_nir_vertex_shader(false),
};
- struct anv_shader_module fsm_2d = {
+ struct anv_shader_module fs_2d = {
.nir = build_nir_copy_fragment_shader(GLSL_SAMPLER_DIM_2D),
};
- struct anv_shader_module fsm_3d = {
+ struct anv_shader_module fs_3d = {
.nir = build_nir_copy_fragment_shader(GLSL_SAMPLER_DIM_3D),
};
- VkShader vs;
- anv_CreateShader(anv_device_to_handle(device),
- &(VkShaderCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO,
- .module = anv_shader_module_to_handle(&vsm),
- .pName = "main",
- }, &vs);
-
- VkShader fs_2d;
- anv_CreateShader(anv_device_to_handle(device),
- &(VkShaderCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO,
- .module = anv_shader_module_to_handle(&fsm_2d),
- .pName = "main",
- }, &fs_2d);
-
- VkShader fs_3d;
- anv_CreateShader(anv_device_to_handle(device),
- &(VkShaderCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO,
- .module = anv_shader_module_to_handle(&fsm_3d),
- .pName = "main",
- }, &fs_3d);
-
VkPipelineVertexInputStateCreateInfo vi_create_info = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
.vertexBindingDescriptionCount = 2,
@@ -329,12 +305,14 @@ anv_device_init_meta_blit_state(struct anv_device *device)
{
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
.stage = VK_SHADER_STAGE_VERTEX,
- .shader = vs,
+ .module = anv_shader_module_to_handle(&vs),
+ .pName = "main",
.pSpecializationInfo = NULL
}, {
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
.stage = VK_SHADER_STAGE_FRAGMENT,
- .shader = VK_NULL_HANDLE, /* TEMPLATE VALUE! FILL ME IN! */
+ .module = VK_NULL_HANDLE, /* TEMPLATE VALUE! FILL ME IN! */
+ .pName = "main",
.pSpecializationInfo = NULL
},
};
@@ -408,22 +386,19 @@ anv_device_init_meta_blit_state(struct anv_device *device)
.use_rectlist = true
};
- pipeline_shader_stages[1].shader = fs_2d;
+ pipeline_shader_stages[1].module = anv_shader_module_to_handle(&fs_2d);
anv_graphics_pipeline_create(anv_device_to_handle(device),
&vk_pipeline_info, &anv_pipeline_info,
NULL, &device->meta_state.blit.pipeline_2d_src);
- pipeline_shader_stages[1].shader = fs_3d;
+ pipeline_shader_stages[1].module = anv_shader_module_to_handle(&fs_3d);
anv_graphics_pipeline_create(anv_device_to_handle(device),
&vk_pipeline_info, &anv_pipeline_info,
NULL, &device->meta_state.blit.pipeline_3d_src);
- anv_DestroyShader(anv_device_to_handle(device), vs);
- anv_DestroyShader(anv_device_to_handle(device), fs_2d);
- anv_DestroyShader(anv_device_to_handle(device), fs_3d);
- ralloc_free(vsm.nir);
- ralloc_free(fsm_2d.nir);
- ralloc_free(fsm_3d.nir);
+ ralloc_free(vs.nir);
+ ralloc_free(fs_2d.nir);
+ ralloc_free(fs_3d.nir);
}
static void
diff --git a/src/vulkan/anv_meta_clear.c b/src/vulkan/anv_meta_clear.c
index d448b661dcf..cac34b3d7d3 100644
--- a/src/vulkan/anv_meta_clear.c
+++ b/src/vulkan/anv_meta_clear.c
@@ -126,24 +126,6 @@ create_pipeline(struct anv_device *device,
struct anv_shader_module vs_m = { .nir = vs_nir };
struct anv_shader_module fs_m = { .nir = fs_nir };
- VkShader vs_h;
- ANV_CALL(CreateShader)(device_h,
- &(VkShaderCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO,
- .module = anv_shader_module_to_handle(&vs_m),
- .pName = "main",
- },
- &vs_h);
-
- VkShader fs_h;
- ANV_CALL(CreateShader)(device_h,
- &(VkShaderCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO,
- .module = anv_shader_module_to_handle(&fs_m),
- .pName = "main",
- },
- &fs_h);
-
VkPipeline pipeline_h;
anv_graphics_pipeline_create(device_h,
&(VkGraphicsPipelineCreateInfo) {
@@ -153,12 +135,14 @@ create_pipeline(struct anv_device *device,
{
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
.stage = VK_SHADER_STAGE_VERTEX,
- .shader = vs_h,
+ .module = anv_shader_module_to_handle(&vs_m),
+ .pName = "main",
},
{
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
.stage = VK_SHADER_STAGE_FRAGMENT,
- .shader = fs_h,
+ .module = anv_shader_module_to_handle(&fs_m),
+ .pName = "main",
},
},
.pVertexInputState = vi_state,
@@ -227,9 +211,6 @@ create_pipeline(struct anv_device *device,
alloc,
&pipeline_h);
- ANV_CALL(DestroyShader)(device_h, vs_h);
- ANV_CALL(DestroyShader)(device_h, fs_h);
-
ralloc_free(vs_nir);
ralloc_free(fs_nir);
diff --git a/src/vulkan/anv_pipeline.c b/src/vulkan/anv_pipeline.c
index f4344a018b8..8b95bce8823 100644
--- a/src/vulkan/anv_pipeline.c
+++ b/src/vulkan/anv_pipeline.c
@@ -75,44 +75,6 @@ void anv_DestroyShaderModule(
anv_free2(&device->alloc, pAllocator, module);
}
-VkResult anv_CreateShader(
- VkDevice _device,
- const VkShaderCreateInfo* pCreateInfo,
- VkShader* pShader)
-{
- ANV_FROM_HANDLE(anv_device, device, _device);
- ANV_FROM_HANDLE(anv_shader_module, module, pCreateInfo->module);
- struct anv_shader *shader;
-
- assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_SHADER_CREATE_INFO);
- assert(pCreateInfo->flags == 0);
-
- const char *name = pCreateInfo->pName ? pCreateInfo->pName : "main";
- size_t name_len = strlen(name);
-
- shader = anv_alloc(&device->alloc, sizeof(*shader) + name_len + 1, 8,
- VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
- if (shader == NULL)
- return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
-
- shader->module = module,
- memcpy(shader->entrypoint, name, name_len + 1);
-
- *pShader = anv_shader_to_handle(shader);
-
- return VK_SUCCESS;
-}
-
-void anv_DestroyShader(
- VkDevice _device,
- VkShader _shader)
-{
- ANV_FROM_HANDLE(anv_device, device, _device);
- ANV_FROM_HANDLE(anv_shader, shader, _shader);
-
- anv_free(&device->alloc, shader);
-}
-
#define SPIR_V_MAGIC_NUMBER 0x07230203
static const gl_shader_stage vk_shader_stage_to_mesa_stage[] = {
@@ -136,9 +98,10 @@ anv_is_scalar_shader_stage(const struct brw_compiler *compiler,
*/
static nir_shader *
anv_shader_compile_to_nir(struct anv_device *device,
- struct anv_shader *shader, VkShaderStage vk_stage)
+ struct anv_shader_module *module,
+ const char *entrypoint_name, VkShaderStage vk_stage)
{
- if (strcmp(shader->entrypoint, "main") != 0) {
+ if (strcmp(entrypoint_name, "main") != 0) {
anv_finishme("Multiple shaders per module not really supported");
}
@@ -149,18 +112,18 @@ anv_shader_compile_to_nir(struct anv_device *device,
compiler->glsl_compiler_options[stage].NirOptions;
nir_shader *nir;
- if (shader->module->nir) {
+ if (module->nir) {
/* Some things such as our meta clear/blit code will give us a NIR
* shader directly. In that case, we just ignore the SPIR-V entirely
* and just use the NIR shader */
- nir = shader->module->nir;
+ nir = module->nir;
nir->options = nir_options;
} else {
- uint32_t *spirv = (uint32_t *) shader->module->data;
+ uint32_t *spirv = (uint32_t *) module->data;
assert(spirv[0] == SPIR_V_MAGIC_NUMBER);
- assert(shader->module->size % 4 == 0);
+ assert(module->size % 4 == 0);
- nir = spirv_to_nir(spirv, shader->module->size / 4, stage, nir_options);
+ nir = spirv_to_nir(spirv, module->size / 4, stage, nir_options);
}
nir_validate_shader(nir);
@@ -172,7 +135,7 @@ anv_shader_compile_to_nir(struct anv_device *device,
*/
nir_function_impl *entrypoint = NULL;
nir_foreach_overload(nir, overload) {
- if (strcmp(shader->entrypoint, overload->function->name) == 0 &&
+ if (strcmp(entrypoint_name, overload->function->name) == 0 &&
overload->impl) {
assert(entrypoint == NULL);
entrypoint = overload->impl;
@@ -339,14 +302,16 @@ populate_cs_prog_key(const struct brw_device_info *devinfo,
static nir_shader *
anv_pipeline_compile(struct anv_pipeline *pipeline,
- struct anv_shader *shader,
+ struct anv_shader_module *module,
+ const char *entrypoint,
VkShaderStage stage,
struct brw_stage_prog_data *prog_data)
{
const struct brw_compiler *compiler =
pipeline->device->instance->physicalDevice.compiler;
- nir_shader *nir = anv_shader_compile_to_nir(pipeline->device, shader, stage);
+ nir_shader *nir = anv_shader_compile_to_nir(pipeline->device,
+ module, entrypoint, stage);
if (nir == NULL)
return NULL;
@@ -451,7 +416,8 @@ anv_pipeline_add_compiled_stage(struct anv_pipeline *pipeline,
static VkResult
anv_pipeline_compile_vs(struct anv_pipeline *pipeline,
const VkGraphicsPipelineCreateInfo *info,
- struct anv_shader *shader)
+ struct anv_shader_module *module,
+ const char *entrypoint)
{
const struct brw_compiler *compiler =
pipeline->device->instance->physicalDevice.compiler;
@@ -464,7 +430,7 @@ anv_pipeline_compile_vs(struct anv_pipeline *pipeline,
memset(prog_data, 0, sizeof(*prog_data));
- nir_shader *nir = anv_pipeline_compile(pipeline, shader,
+ nir_shader *nir = anv_pipeline_compile(pipeline, module, entrypoint,
VK_SHADER_STAGE_VERTEX,
&prog_data->base.base);
if (nir == NULL)
@@ -472,7 +438,7 @@ anv_pipeline_compile_vs(struct anv_pipeline *pipeline,
void *mem_ctx = ralloc_context(NULL);
- if (shader->module->nir == NULL)
+ if (module->nir == NULL)
ralloc_steal(mem_ctx, nir);
prog_data->inputs_read = nir->info.inputs_read;
@@ -513,7 +479,8 @@ anv_pipeline_compile_vs(struct anv_pipeline *pipeline,
static VkResult
anv_pipeline_compile_gs(struct anv_pipeline *pipeline,
const VkGraphicsPipelineCreateInfo *info,
- struct anv_shader *shader)
+ struct anv_shader_module *module,
+ const char *entrypoint)
{
const struct brw_compiler *compiler =
pipeline->device->instance->physicalDevice.compiler;
@@ -526,7 +493,7 @@ anv_pipeline_compile_gs(struct anv_pipeline *pipeline,
memset(prog_data, 0, sizeof(*prog_data));
- nir_shader *nir = anv_pipeline_compile(pipeline, shader,
+ nir_shader *nir = anv_pipeline_compile(pipeline, module, entrypoint,
VK_SHADER_STAGE_GEOMETRY,
&prog_data->base.base);
if (nir == NULL)
@@ -534,7 +501,7 @@ anv_pipeline_compile_gs(struct anv_pipeline *pipeline,
void *mem_ctx = ralloc_context(NULL);
- if (shader->module->nir == NULL)
+ if (module->nir == NULL)
ralloc_steal(mem_ctx, nir);
brw_compute_vue_map(&pipeline->device->info,
@@ -567,7 +534,8 @@ anv_pipeline_compile_gs(struct anv_pipeline *pipeline,
static VkResult
anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
const VkGraphicsPipelineCreateInfo *info,
- struct anv_shader *shader)
+ struct anv_shader_module *module,
+ const char *entrypoint)
{
const struct brw_compiler *compiler =
pipeline->device->instance->physicalDevice.compiler;
@@ -585,7 +553,7 @@ anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
prog_data->binding_table.render_target_start = 0;
- nir_shader *nir = anv_pipeline_compile(pipeline, shader,
+ nir_shader *nir = anv_pipeline_compile(pipeline, module, entrypoint,
VK_SHADER_STAGE_FRAGMENT,
&prog_data->base);
if (nir == NULL)
@@ -593,7 +561,7 @@ anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
void *mem_ctx = ralloc_context(NULL);
- if (shader->module->nir == NULL)
+ if (module->nir == NULL)
ralloc_steal(mem_ctx, nir);
unsigned code_size;
@@ -643,7 +611,8 @@ anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
VkResult
anv_pipeline_compile_cs(struct anv_pipeline *pipeline,
const VkComputePipelineCreateInfo *info,
- struct anv_shader *shader)
+ struct anv_shader_module *module,
+ const char *entrypoint)
{
const struct brw_compiler *compiler =
pipeline->device->instance->physicalDevice.compiler;
@@ -656,7 +625,7 @@ anv_pipeline_compile_cs(struct anv_pipeline *pipeline,
memset(prog_data, 0, sizeof(*prog_data));
- nir_shader *nir = anv_pipeline_compile(pipeline, shader,
+ nir_shader *nir = anv_pipeline_compile(pipeline, module, entrypoint,
VK_SHADER_STAGE_COMPUTE,
&prog_data->base);
if (nir == NULL)
@@ -664,7 +633,7 @@ anv_pipeline_compile_cs(struct anv_pipeline *pipeline,
void *mem_ctx = ralloc_context(NULL);
- if (shader->module->nir == NULL)
+ if (module->nir == NULL)
ralloc_steal(mem_ctx, nir);
unsigned code_size;
@@ -1009,17 +978,19 @@ anv_pipeline_init(struct anv_pipeline *pipeline, struct anv_device *device,
pipeline->total_scratch = 0;
for (uint32_t i = 0; i < pCreateInfo->stageCount; i++) {
- ANV_FROM_HANDLE(anv_shader, shader, pCreateInfo->pStages[i].shader);
+ ANV_FROM_HANDLE(anv_shader_module, module,
+ pCreateInfo->pStages[i].module);
+ const char *entrypoint = pCreateInfo->pStages[i].pName;
switch (pCreateInfo->pStages[i].stage) {
case VK_SHADER_STAGE_VERTEX:
- anv_pipeline_compile_vs(pipeline, pCreateInfo, shader);
+ anv_pipeline_compile_vs(pipeline, pCreateInfo, module, entrypoint);
break;
case VK_SHADER_STAGE_GEOMETRY:
- anv_pipeline_compile_gs(pipeline, pCreateInfo, shader);
+ anv_pipeline_compile_gs(pipeline, pCreateInfo, module, entrypoint);
break;
case VK_SHADER_STAGE_FRAGMENT:
- anv_pipeline_compile_fs(pipeline, pCreateInfo, shader);
+ anv_pipeline_compile_fs(pipeline, pCreateInfo, module, entrypoint);
break;
default:
anv_finishme("Unsupported shader stage");
diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h
index 964e6d8cf57..940d1662c1f 100644
--- a/src/vulkan/anv_private.h
+++ b/src/vulkan/anv_private.h
@@ -1163,11 +1163,6 @@ struct anv_shader_module {
char data[0];
};
-struct anv_shader {
- struct anv_shader_module * module;
- char entrypoint[0];
-};
-
struct anv_pipeline {
struct anv_device * device;
struct anv_batch batch;
@@ -1253,7 +1248,8 @@ anv_pipeline_init(struct anv_pipeline *pipeline, struct anv_device *device,
VkResult
anv_pipeline_compile_cs(struct anv_pipeline *pipeline,
const VkComputePipelineCreateInfo *info,
- struct anv_shader *shader);
+ struct anv_shader_module *module,
+ const char *entrypoint_name);
VkResult
anv_graphics_pipeline_create(VkDevice device,
@@ -1607,7 +1603,6 @@ ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_pipeline_layout, VkPipelineLayout)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_query_pool, VkQueryPool)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_render_pass, VkRenderPass)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_sampler, VkSampler)
-ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_shader, VkShader)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_shader_module, VkShaderModule)
#define ANV_DEFINE_STRUCT_CASTS(__anv_type, __VkType) \
diff --git a/src/vulkan/gen8_pipeline.c b/src/vulkan/gen8_pipeline.c
index f2777c02d4a..106f82d36fa 100644
--- a/src/vulkan/gen8_pipeline.c
+++ b/src/vulkan/gen8_pipeline.c
@@ -710,8 +710,9 @@ VkResult genX(compute_pipeline_create)(
pipeline->total_scratch = 0;
assert(pCreateInfo->stage.stage == VK_SHADER_STAGE_COMPUTE);
- ANV_FROM_HANDLE(anv_shader, shader, pCreateInfo->stage.shader);
- anv_pipeline_compile_cs(pipeline, pCreateInfo, shader);
+ ANV_FROM_HANDLE(anv_shader_module, module, pCreateInfo->stage.module);
+ anv_pipeline_compile_cs(pipeline, pCreateInfo, module,
+ pCreateInfo->stage.pName);
pipeline->use_repclear = false;