diff options
author | Jason Ekstrand <[email protected]> | 2015-09-24 14:20:35 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-09-24 14:45:58 -0700 |
commit | a95f51c1d79848941dae2965dc0d2db4d1fd3d18 (patch) | |
tree | 3122eb8aeefd8eb32f97b1088c75c0202b63d99f | |
parent | 00d18a661f7685fd3742337674deca372ad7cbc4 (diff) |
anv: Add a global dispatch table for use in meta operations
-rw-r--r-- | src/vulkan/anv_device.c | 4 | ||||
-rw-r--r-- | src/vulkan/anv_meta.c | 19 | ||||
-rw-r--r-- | src/vulkan/anv_private.h | 10 | ||||
-rw-r--r-- | src/vulkan/glsl_scraper.py | 11 |
4 files changed, 29 insertions, 15 deletions
diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c index 9d3b5dbfa0a..75a889f134d 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 3ab1ceabb92..30da2fee90f 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 7e5982db645..07a1d97c65b 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 4963742ea36..244cb4888d5 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; \\ }) """)) |