From: Jason Ekstrand Date: Thu, 24 Sep 2015 21:20:35 +0000 (-0700) Subject: anv: Add a global dispatch table for use in meta operations X-Git-Tag: upstream/17.1.0~11012^2~1341 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a95f51c1d79848941dae2965dc0d2db4d1fd3d18;p=platform%2Fupstream%2Fmesa.git anv: Add a global dispatch table for use in meta operations --- diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c index 9d3b5db..75a889f 100644 --- a/src/vulkan/anv_device.c +++ b/src/vulkan/anv_device.c @@ -31,6 +31,8 @@ #include "mesa/main/git_sha1.h" #include "util/strtod.h" +struct anv_dispatch_table dtable; + static VkResult anv_physical_device_init(struct anv_physical_device *device, struct anv_instance *instance, @@ -794,7 +796,7 @@ VkResult anv_QueueWaitIdle( { ANV_FROM_HANDLE(anv_queue, queue, _queue); - return vkDeviceWaitIdle(anv_device_to_handle(queue->device)); + return ANV_CALL(DeviceWaitIdle)(anv_device_to_handle(queue->device)); } VkResult anv_DeviceWaitIdle( diff --git a/src/vulkan/anv_meta.c b/src/vulkan/anv_meta.c index 3ab1cea..30da2fe 100644 --- a/src/vulkan/anv_meta.c +++ b/src/vulkan/anv_meta.c @@ -318,7 +318,8 @@ meta_emit_clear(struct anv_cmd_buffer *cmd_buffer, anv_CmdBindDynamicColorBlendState(anv_cmd_buffer_to_handle(cmd_buffer), device->meta_state.shared.cb_state); - vkCmdDraw(anv_cmd_buffer_to_handle(cmd_buffer), 0, 3, 0, num_instances); + ANV_CALL(CmdDraw)(anv_cmd_buffer_to_handle(cmd_buffer), + 0, 3, 0, num_instances); } void @@ -802,7 +803,7 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer, .dependencyCount = 0, }, &pass); - vkCmdBeginRenderPass(anv_cmd_buffer_to_handle(cmd_buffer), + ANV_CALL(CmdBeginRenderPass)(anv_cmd_buffer_to_handle(cmd_buffer), &(VkRenderPassBeginInfo) { .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, .renderPass = pass, @@ -845,9 +846,9 @@ meta_emit_blit(struct anv_cmd_buffer *cmd_buffer, device->meta_state.blit.pipeline_layout, 0, 1, &set, 0, NULL); - vkCmdDraw(anv_cmd_buffer_to_handle(cmd_buffer), 0, 3, 0, 1); + ANV_CALL(CmdDraw)(anv_cmd_buffer_to_handle(cmd_buffer), 0, 3, 0, 1); - vkCmdEndRenderPass(anv_cmd_buffer_to_handle(cmd_buffer)); + ANV_CALL(CmdEndRenderPass)(anv_cmd_buffer_to_handle(cmd_buffer)); /* At the point where we emit the draw call, all data from the * descriptor sets, etc. has been used. We are free to delete it. @@ -1531,7 +1532,7 @@ void anv_CmdClearColorImage( .dependencyCount = 0, }, &pass); - vkCmdBeginRenderPass(anv_cmd_buffer_to_handle(cmd_buffer), + ANV_CALL(CmdBeginRenderPass)(anv_cmd_buffer_to_handle(cmd_buffer), &(VkRenderPassBeginInfo) { .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, .renderArea = { @@ -1559,7 +1560,7 @@ void anv_CmdClearColorImage( meta_emit_clear(cmd_buffer, 1, &instance_data, (VkClearDepthStencilValue) {0}); - vkCmdEndRenderPass(anv_cmd_buffer_to_handle(cmd_buffer)); + ANV_CALL(CmdEndRenderPass)(anv_cmd_buffer_to_handle(cmd_buffer)); } } } @@ -1621,19 +1622,19 @@ anv_device_init_meta(struct anv_device *device) anv_device_init_meta_clear_state(device); anv_device_init_meta_blit_state(device); - vkCreateDynamicRasterState(anv_device_to_handle(device), + ANV_CALL(CreateDynamicRasterState)(anv_device_to_handle(device), &(VkDynamicRasterStateCreateInfo) { .sType = VK_STRUCTURE_TYPE_DYNAMIC_RASTER_STATE_CREATE_INFO, }, &device->meta_state.shared.rs_state); - vkCreateDynamicColorBlendState(anv_device_to_handle(device), + ANV_CALL(CreateDynamicColorBlendState)(anv_device_to_handle(device), &(VkDynamicColorBlendStateCreateInfo) { .sType = VK_STRUCTURE_TYPE_DYNAMIC_COLOR_BLEND_STATE_CREATE_INFO }, &device->meta_state.shared.cb_state); - vkCreateDynamicDepthStencilState(anv_device_to_handle(device), + ANV_CALL(CreateDynamicDepthStencilState)(anv_device_to_handle(device), &(VkDynamicDepthStencilStateCreateInfo) { .sType = VK_STRUCTURE_TYPE_DYNAMIC_DEPTH_STENCIL_STATE_CREATE_INFO }, diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 7e5982d..07a1d97 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -369,6 +369,16 @@ void anv_bo_pool_free(struct anv_bo_pool *pool, const struct anv_bo *bo); void *anv_resolve_entrypoint(uint32_t index); +extern struct anv_dispatch_table dtable; + +#define ANV_CALL(func) ({ \ + if (dtable.func == NULL) { \ + size_t idx = offsetof(struct anv_dispatch_table, func) / sizeof(void *); \ + dtable.entrypoints[idx] = anv_resolve_entrypoint(idx); \ + } \ + dtable.func; \ +}) + struct anv_physical_device { struct anv_instance * instance; diff --git a/src/vulkan/glsl_scraper.py b/src/vulkan/glsl_scraper.py index 4963742..244cb488 100644 --- a/src/vulkan/glsl_scraper.py +++ b/src/vulkan/glsl_scraper.py @@ -240,11 +240,12 @@ with open_file(outfname, 'w') as outfile: #define _ANV_SPIRV_MODULE_INFO2(_line) _anv_glsl_helpers_shader ## _line ## _info #define _ANV_SPIRV_MODULE_INFO(_line) _ANV_SPIRV_MODULE_INFO2(_line) - #define GLSL_VK_SHADER_MODULE(device, stage, ...) ({ \\ - VkShaderModule __module; \\ - vkCreateShaderModule(anv_device_to_handle(device), \\ - &_ANV_SPIRV_MODULE_INFO(__LINE__), &__module); \\ - __module; \\ + #define GLSL_VK_SHADER_MODULE(device, stage, ...) ({ \\ + VkShaderModule __module; \\ + ANV_CALL(CreateShaderModule)(anv_device_to_handle(device), \\ + &_ANV_SPIRV_MODULE_INFO(__LINE__), \\ + &__module); \\ + __module; \\ }) """))