vk/0.210.0: Remove VkShader

This commit is contained in:
Jason Ekstrand
2015-12-02 14:35:07 -08:00
parent e6ab06ae7f
commit e10dc002e9
6 changed files with 58 additions and 157 deletions

View File

@@ -79,7 +79,6 @@ VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkQueryPool)
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferView) VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferView)
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImageView) VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImageView)
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkShaderModule) VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkShaderModule)
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkShader)
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineCache) VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineCache)
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineLayout) VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineLayout)
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkRenderPass) VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkRenderPass)
@@ -136,7 +135,6 @@ typedef enum VkStructureType {
VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO = 2, VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO = 2,
VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO = 3, VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO = 3,
VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO = 4, VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO = 4,
VK_STRUCTURE_TYPE_SHADER_CREATE_INFO = 5,
VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO = 6, VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO = 6,
VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO = 7, VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO = 7,
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 8, VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 8,
@@ -921,7 +919,6 @@ typedef VkFlags VkBufferViewCreateFlags;
typedef VkFlags VkImageViewCreateFlags; typedef VkFlags VkImageViewCreateFlags;
typedef VkFlags VkShaderModuleCreateFlags; typedef VkFlags VkShaderModuleCreateFlags;
typedef VkFlags VkPipelineCacheCreateFlags; typedef VkFlags VkPipelineCacheCreateFlags;
typedef VkFlags VkShaderCreateFlags;
typedef enum VkPipelineCreateFlagBits { typedef enum VkPipelineCreateFlagBits {
VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT = 0x00000001, VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT = 0x00000001,
@@ -1582,15 +1579,6 @@ typedef struct VkShaderModuleCreateInfo {
const uint32_t* pCode; const uint32_t* pCode;
} VkShaderModuleCreateInfo; } VkShaderModuleCreateInfo;
typedef struct {
VkStructureType sType;
const void* pNext;
VkShaderModule module;
const char* pName;
VkShaderCreateFlags flags;
VkShaderStage stage;
} VkShaderCreateInfo;
typedef struct VkPipelineCacheCreateInfo { typedef struct VkPipelineCacheCreateInfo {
VkStructureType sType; VkStructureType sType;
const void* pNext; const void* pNext;
@@ -1617,7 +1605,8 @@ typedef struct VkPipelineShaderStageCreateInfo {
const void* pNext; const void* pNext;
VkPipelineShaderStageCreateFlags flags; VkPipelineShaderStageCreateFlags flags;
VkShaderStage stage; VkShaderStage stage;
VkShader shader; VkShaderModule module;
const char* pName;
const VkSpecializationInfo* pSpecializationInfo; const VkSpecializationInfo* pSpecializationInfo;
} VkPipelineShaderStageCreateInfo; } VkPipelineShaderStageCreateInfo;
@@ -2207,8 +2196,6 @@ typedef VkResult (VKAPI_PTR *PFN_vkCreateImageView)(VkDevice device, const VkIma
typedef void (VKAPI_PTR *PFN_vkDestroyImageView)(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator); typedef void (VKAPI_PTR *PFN_vkDestroyImageView)(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator);
typedef VkResult (VKAPI_PTR *PFN_vkCreateShaderModule)(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule); typedef VkResult (VKAPI_PTR *PFN_vkCreateShaderModule)(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule);
typedef void (VKAPI_PTR *PFN_vkDestroyShaderModule)(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator); typedef void (VKAPI_PTR *PFN_vkDestroyShaderModule)(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator);
typedef VkResult (VKAPI_PTR *PFN_vkCreateShader)(VkDevice device, const VkShaderCreateInfo* pCreateInfo, VkShader* pShader);
typedef void (VKAPI_PTR *PFN_vkDestroyShader)(VkDevice device, VkShader shader);
typedef VkResult (VKAPI_PTR *PFN_vkCreatePipelineCache)(VkDevice device, const VkPipelineCacheCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineCache* pPipelineCache); typedef VkResult (VKAPI_PTR *PFN_vkCreatePipelineCache)(VkDevice device, const VkPipelineCacheCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineCache* pPipelineCache);
typedef void (VKAPI_PTR *PFN_vkDestroyPipelineCache)(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* pAllocator); typedef void (VKAPI_PTR *PFN_vkDestroyPipelineCache)(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* pAllocator);
typedef VkResult (VKAPI_PTR *PFN_vkGetPipelineCacheData)(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData); typedef VkResult (VKAPI_PTR *PFN_vkGetPipelineCacheData)(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData);
@@ -2612,15 +2599,6 @@ VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule(
VkShaderModule shaderModule, VkShaderModule shaderModule,
const VkAllocationCallbacks* pAllocator); const VkAllocationCallbacks* pAllocator);
VKAPI_ATTR VkResult VKAPI_CALL vkCreateShader(
VkDevice device,
const VkShaderCreateInfo* pCreateInfo,
VkShader* pShader);
VKAPI_ATTR void VKAPI_CALL vkDestroyShader(
VkDevice device,
VkShader shader);
VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache( VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache(
VkDevice device, VkDevice device,
const VkPipelineCacheCreateInfo* pCreateInfo, const VkPipelineCacheCreateInfo* pCreateInfo,

View File

@@ -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 * to provide GLSL source for the vertex shader so that the compiler
* does not dead-code our inputs. * does not dead-code our inputs.
*/ */
struct anv_shader_module vsm = { struct anv_shader_module vs = {
.nir = build_nir_vertex_shader(false), .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), .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), .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 = { VkPipelineVertexInputStateCreateInfo vi_create_info = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
.vertexBindingDescriptionCount = 2, .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, .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
.stage = VK_SHADER_STAGE_VERTEX, .stage = VK_SHADER_STAGE_VERTEX,
.shader = vs, .module = anv_shader_module_to_handle(&vs),
.pName = "main",
.pSpecializationInfo = NULL .pSpecializationInfo = NULL
}, { }, {
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
.stage = VK_SHADER_STAGE_FRAGMENT, .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 .pSpecializationInfo = NULL
}, },
}; };
@@ -408,22 +386,19 @@ anv_device_init_meta_blit_state(struct anv_device *device)
.use_rectlist = true .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), anv_graphics_pipeline_create(anv_device_to_handle(device),
&vk_pipeline_info, &anv_pipeline_info, &vk_pipeline_info, &anv_pipeline_info,
NULL, &device->meta_state.blit.pipeline_2d_src); 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), anv_graphics_pipeline_create(anv_device_to_handle(device),
&vk_pipeline_info, &anv_pipeline_info, &vk_pipeline_info, &anv_pipeline_info,
NULL, &device->meta_state.blit.pipeline_3d_src); NULL, &device->meta_state.blit.pipeline_3d_src);
anv_DestroyShader(anv_device_to_handle(device), vs); ralloc_free(vs.nir);
anv_DestroyShader(anv_device_to_handle(device), fs_2d); ralloc_free(fs_2d.nir);
anv_DestroyShader(anv_device_to_handle(device), fs_3d); ralloc_free(fs_3d.nir);
ralloc_free(vsm.nir);
ralloc_free(fsm_2d.nir);
ralloc_free(fsm_3d.nir);
} }
static void static void

View File

@@ -126,24 +126,6 @@ create_pipeline(struct anv_device *device,
struct anv_shader_module vs_m = { .nir = vs_nir }; struct anv_shader_module vs_m = { .nir = vs_nir };
struct anv_shader_module fs_m = { .nir = fs_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; VkPipeline pipeline_h;
anv_graphics_pipeline_create(device_h, anv_graphics_pipeline_create(device_h,
&(VkGraphicsPipelineCreateInfo) { &(VkGraphicsPipelineCreateInfo) {
@@ -153,12 +135,14 @@ create_pipeline(struct anv_device *device,
{ {
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
.stage = VK_SHADER_STAGE_VERTEX, .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, .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
.stage = VK_SHADER_STAGE_FRAGMENT, .stage = VK_SHADER_STAGE_FRAGMENT,
.shader = fs_h, .module = anv_shader_module_to_handle(&fs_m),
.pName = "main",
}, },
}, },
.pVertexInputState = vi_state, .pVertexInputState = vi_state,
@@ -227,9 +211,6 @@ create_pipeline(struct anv_device *device,
alloc, alloc,
&pipeline_h); &pipeline_h);
ANV_CALL(DestroyShader)(device_h, vs_h);
ANV_CALL(DestroyShader)(device_h, fs_h);
ralloc_free(vs_nir); ralloc_free(vs_nir);
ralloc_free(fs_nir); ralloc_free(fs_nir);

View File

@@ -75,44 +75,6 @@ void anv_DestroyShaderModule(
anv_free2(&device->alloc, pAllocator, module); 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 #define SPIR_V_MAGIC_NUMBER 0x07230203
static const gl_shader_stage vk_shader_stage_to_mesa_stage[] = { 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 * static nir_shader *
anv_shader_compile_to_nir(struct anv_device *device, 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"); 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; compiler->glsl_compiler_options[stage].NirOptions;
nir_shader *nir; nir_shader *nir;
if (shader->module->nir) { if (module->nir) {
/* Some things such as our meta clear/blit code will give us a 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 * shader directly. In that case, we just ignore the SPIR-V entirely
* and just use the NIR shader */ * and just use the NIR shader */
nir = shader->module->nir; nir = module->nir;
nir->options = nir_options; nir->options = nir_options;
} else { } else {
uint32_t *spirv = (uint32_t *) shader->module->data; uint32_t *spirv = (uint32_t *) module->data;
assert(spirv[0] == SPIR_V_MAGIC_NUMBER); 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); nir_validate_shader(nir);
@@ -172,7 +135,7 @@ anv_shader_compile_to_nir(struct anv_device *device,
*/ */
nir_function_impl *entrypoint = NULL; nir_function_impl *entrypoint = NULL;
nir_foreach_overload(nir, overload) { nir_foreach_overload(nir, overload) {
if (strcmp(shader->entrypoint, overload->function->name) == 0 && if (strcmp(entrypoint_name, overload->function->name) == 0 &&
overload->impl) { overload->impl) {
assert(entrypoint == NULL); assert(entrypoint == NULL);
entrypoint = overload->impl; entrypoint = overload->impl;
@@ -339,14 +302,16 @@ populate_cs_prog_key(const struct brw_device_info *devinfo,
static nir_shader * static nir_shader *
anv_pipeline_compile(struct anv_pipeline *pipeline, anv_pipeline_compile(struct anv_pipeline *pipeline,
struct anv_shader *shader, struct anv_shader_module *module,
const char *entrypoint,
VkShaderStage stage, VkShaderStage stage,
struct brw_stage_prog_data *prog_data) struct brw_stage_prog_data *prog_data)
{ {
const struct brw_compiler *compiler = const struct brw_compiler *compiler =
pipeline->device->instance->physicalDevice.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) if (nir == NULL)
return NULL; return NULL;
@@ -451,7 +416,8 @@ anv_pipeline_add_compiled_stage(struct anv_pipeline *pipeline,
static VkResult static VkResult
anv_pipeline_compile_vs(struct anv_pipeline *pipeline, anv_pipeline_compile_vs(struct anv_pipeline *pipeline,
const VkGraphicsPipelineCreateInfo *info, const VkGraphicsPipelineCreateInfo *info,
struct anv_shader *shader) struct anv_shader_module *module,
const char *entrypoint)
{ {
const struct brw_compiler *compiler = const struct brw_compiler *compiler =
pipeline->device->instance->physicalDevice.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)); 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, VK_SHADER_STAGE_VERTEX,
&prog_data->base.base); &prog_data->base.base);
if (nir == NULL) if (nir == NULL)
@@ -472,7 +438,7 @@ anv_pipeline_compile_vs(struct anv_pipeline *pipeline,
void *mem_ctx = ralloc_context(NULL); void *mem_ctx = ralloc_context(NULL);
if (shader->module->nir == NULL) if (module->nir == NULL)
ralloc_steal(mem_ctx, nir); ralloc_steal(mem_ctx, nir);
prog_data->inputs_read = nir->info.inputs_read; prog_data->inputs_read = nir->info.inputs_read;
@@ -513,7 +479,8 @@ anv_pipeline_compile_vs(struct anv_pipeline *pipeline,
static VkResult static VkResult
anv_pipeline_compile_gs(struct anv_pipeline *pipeline, anv_pipeline_compile_gs(struct anv_pipeline *pipeline,
const VkGraphicsPipelineCreateInfo *info, const VkGraphicsPipelineCreateInfo *info,
struct anv_shader *shader) struct anv_shader_module *module,
const char *entrypoint)
{ {
const struct brw_compiler *compiler = const struct brw_compiler *compiler =
pipeline->device->instance->physicalDevice.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)); 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, VK_SHADER_STAGE_GEOMETRY,
&prog_data->base.base); &prog_data->base.base);
if (nir == NULL) if (nir == NULL)
@@ -534,7 +501,7 @@ anv_pipeline_compile_gs(struct anv_pipeline *pipeline,
void *mem_ctx = ralloc_context(NULL); void *mem_ctx = ralloc_context(NULL);
if (shader->module->nir == NULL) if (module->nir == NULL)
ralloc_steal(mem_ctx, nir); ralloc_steal(mem_ctx, nir);
brw_compute_vue_map(&pipeline->device->info, brw_compute_vue_map(&pipeline->device->info,
@@ -567,7 +534,8 @@ anv_pipeline_compile_gs(struct anv_pipeline *pipeline,
static VkResult static VkResult
anv_pipeline_compile_fs(struct anv_pipeline *pipeline, anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
const VkGraphicsPipelineCreateInfo *info, const VkGraphicsPipelineCreateInfo *info,
struct anv_shader *shader) struct anv_shader_module *module,
const char *entrypoint)
{ {
const struct brw_compiler *compiler = const struct brw_compiler *compiler =
pipeline->device->instance->physicalDevice.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; 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, VK_SHADER_STAGE_FRAGMENT,
&prog_data->base); &prog_data->base);
if (nir == NULL) if (nir == NULL)
@@ -593,7 +561,7 @@ anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
void *mem_ctx = ralloc_context(NULL); void *mem_ctx = ralloc_context(NULL);
if (shader->module->nir == NULL) if (module->nir == NULL)
ralloc_steal(mem_ctx, nir); ralloc_steal(mem_ctx, nir);
unsigned code_size; unsigned code_size;
@@ -643,7 +611,8 @@ anv_pipeline_compile_fs(struct anv_pipeline *pipeline,
VkResult VkResult
anv_pipeline_compile_cs(struct anv_pipeline *pipeline, anv_pipeline_compile_cs(struct anv_pipeline *pipeline,
const VkComputePipelineCreateInfo *info, const VkComputePipelineCreateInfo *info,
struct anv_shader *shader) struct anv_shader_module *module,
const char *entrypoint)
{ {
const struct brw_compiler *compiler = const struct brw_compiler *compiler =
pipeline->device->instance->physicalDevice.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)); 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, VK_SHADER_STAGE_COMPUTE,
&prog_data->base); &prog_data->base);
if (nir == NULL) if (nir == NULL)
@@ -664,7 +633,7 @@ anv_pipeline_compile_cs(struct anv_pipeline *pipeline,
void *mem_ctx = ralloc_context(NULL); void *mem_ctx = ralloc_context(NULL);
if (shader->module->nir == NULL) if (module->nir == NULL)
ralloc_steal(mem_ctx, nir); ralloc_steal(mem_ctx, nir);
unsigned code_size; unsigned code_size;
@@ -1009,17 +978,19 @@ anv_pipeline_init(struct anv_pipeline *pipeline, struct anv_device *device,
pipeline->total_scratch = 0; pipeline->total_scratch = 0;
for (uint32_t i = 0; i < pCreateInfo->stageCount; i++) { 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) { switch (pCreateInfo->pStages[i].stage) {
case VK_SHADER_STAGE_VERTEX: case VK_SHADER_STAGE_VERTEX:
anv_pipeline_compile_vs(pipeline, pCreateInfo, shader); anv_pipeline_compile_vs(pipeline, pCreateInfo, module, entrypoint);
break; break;
case VK_SHADER_STAGE_GEOMETRY: case VK_SHADER_STAGE_GEOMETRY:
anv_pipeline_compile_gs(pipeline, pCreateInfo, shader); anv_pipeline_compile_gs(pipeline, pCreateInfo, module, entrypoint);
break; break;
case VK_SHADER_STAGE_FRAGMENT: case VK_SHADER_STAGE_FRAGMENT:
anv_pipeline_compile_fs(pipeline, pCreateInfo, shader); anv_pipeline_compile_fs(pipeline, pCreateInfo, module, entrypoint);
break; break;
default: default:
anv_finishme("Unsupported shader stage"); anv_finishme("Unsupported shader stage");

View File

@@ -1163,11 +1163,6 @@ struct anv_shader_module {
char data[0]; char data[0];
}; };
struct anv_shader {
struct anv_shader_module * module;
char entrypoint[0];
};
struct anv_pipeline { struct anv_pipeline {
struct anv_device * device; struct anv_device * device;
struct anv_batch batch; struct anv_batch batch;
@@ -1253,7 +1248,8 @@ anv_pipeline_init(struct anv_pipeline *pipeline, struct anv_device *device,
VkResult VkResult
anv_pipeline_compile_cs(struct anv_pipeline *pipeline, anv_pipeline_compile_cs(struct anv_pipeline *pipeline,
const VkComputePipelineCreateInfo *info, const VkComputePipelineCreateInfo *info,
struct anv_shader *shader); struct anv_shader_module *module,
const char *entrypoint_name);
VkResult VkResult
anv_graphics_pipeline_create(VkDevice device, 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_query_pool, VkQueryPool)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_render_pass, VkRenderPass) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_render_pass, VkRenderPass)
ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_sampler, VkSampler) 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) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_shader_module, VkShaderModule)
#define ANV_DEFINE_STRUCT_CASTS(__anv_type, __VkType) \ #define ANV_DEFINE_STRUCT_CASTS(__anv_type, __VkType) \

View File

@@ -710,8 +710,9 @@ VkResult genX(compute_pipeline_create)(
pipeline->total_scratch = 0; pipeline->total_scratch = 0;
assert(pCreateInfo->stage.stage == VK_SHADER_STAGE_COMPUTE); assert(pCreateInfo->stage.stage == VK_SHADER_STAGE_COMPUTE);
ANV_FROM_HANDLE(anv_shader, shader, pCreateInfo->stage.shader); ANV_FROM_HANDLE(anv_shader_module, module, pCreateInfo->stage.module);
anv_pipeline_compile_cs(pipeline, pCreateInfo, shader); anv_pipeline_compile_cs(pipeline, pCreateInfo, module,
pCreateInfo->stage.pName);
pipeline->use_repclear = false; pipeline->use_repclear = false;