diff options
author | Kristian Høgsberg Kristensen <[email protected]> | 2015-08-13 21:48:19 -0700 |
---|---|---|
committer | Kristian Høgsberg Kristensen <[email protected]> | 2015-08-24 13:45:40 -0700 |
commit | fb428727e03d9b819fc9ef510941e001ac03877b (patch) | |
tree | 3625df9129e0841e3fd3140909eaa4c49f82dde2 /src/vulkan/anv_device.c | |
parent | 74556b076a191fb1e6e0b0204a49ee33962e5112 (diff) |
vk: Move anv_CreateBufferView to anv_gen8.c
Signed-off-by: Kristian Høgsberg Kristensen <[email protected]>
Diffstat (limited to 'src/vulkan/anv_device.c')
-rw-r--r-- | src/vulkan/anv_device.c | 98 |
1 files changed, 26 insertions, 72 deletions
diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c index ba0966aa3b2..78c35dd83fe 100644 --- a/src/vulkan/anv_device.c +++ b/src/vulkan/anv_device.c @@ -1324,90 +1324,44 @@ VkResult anv_DestroyBuffer( return VK_SUCCESS; } -// Buffer view functions - -void -anv_fill_buffer_surface_state(void *state, const struct anv_format *format, - uint32_t offset, uint32_t range) -{ - /* This assumes RGBA float format. */ - uint32_t stride = 4; - uint32_t num_elements = range / stride; - - struct GEN8_RENDER_SURFACE_STATE surface_state = { - .SurfaceType = SURFTYPE_BUFFER, - .SurfaceArray = false, - .SurfaceFormat = format->surface_format, - .SurfaceVerticalAlignment = VALIGN4, - .SurfaceHorizontalAlignment = HALIGN4, - .TileMode = LINEAR, - .VerticalLineStride = 0, - .VerticalLineStrideOffset = 0, - .SamplerL2BypassModeDisable = true, - .RenderCacheReadWriteMode = WriteOnlyCache, - .MemoryObjectControlState = GEN8_MOCS, - .BaseMipLevel = 0.0, - .SurfaceQPitch = 0, - .Height = (num_elements >> 7) & 0x3fff, - .Width = num_elements & 0x7f, - .Depth = (num_elements >> 21) & 0x3f, - .SurfacePitch = stride - 1, - .MinimumArrayElement = 0, - .NumberofMultisamples = MULTISAMPLECOUNT_1, - .XOffset = 0, - .YOffset = 0, - .SurfaceMinLOD = 0, - .MIPCountLOD = 0, - .AuxiliarySurfaceMode = AUX_NONE, - .RedClearColor = 0, - .GreenClearColor = 0, - .BlueClearColor = 0, - .AlphaClearColor = 0, - .ShaderChannelSelectRed = SCS_RED, - .ShaderChannelSelectGreen = SCS_GREEN, - .ShaderChannelSelectBlue = SCS_BLUE, - .ShaderChannelSelectAlpha = SCS_ALPHA, - .ResourceMinLOD = 0.0, - /* FIXME: We assume that the image must be bound at this time. */ - .SurfaceBaseAddress = { NULL, offset }, - }; - - GEN8_RENDER_SURFACE_STATE_pack(NULL, state, &surface_state); -} - -VkResult anv_CreateBufferView( - VkDevice _device, - const VkBufferViewCreateInfo* pCreateInfo, - VkBufferView* pView) +VkResult +anv_buffer_view_create( + struct anv_device * device, + const VkBufferViewCreateInfo* pCreateInfo, + struct anv_buffer_view ** view_out) { - ANV_FROM_HANDLE(anv_device, device, _device); ANV_FROM_HANDLE(anv_buffer, buffer, pCreateInfo->buffer); - struct anv_buffer_view *bview; - struct anv_surface_view *view; + struct anv_buffer_view *view; assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO); - bview = anv_device_alloc(device, sizeof(*view), 8, - VK_SYSTEM_ALLOC_TYPE_API_OBJECT); - if (bview == NULL) + view = anv_device_alloc(device, sizeof(*view), 8, + VK_SYSTEM_ALLOC_TYPE_API_OBJECT); + if (view == NULL) return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - view = &bview->view; - view->bo = buffer->bo; - view->offset = buffer->offset + pCreateInfo->offset; - view->surface_state = - anv_state_pool_alloc(&device->surface_state_pool, 64, 64); - view->format = anv_format_for_vk_format(pCreateInfo->format); - view->range = pCreateInfo->range; - - anv_fill_buffer_surface_state(view->surface_state.map, view->format, - view->offset, pCreateInfo->range); + view->view = (struct anv_surface_view) { + .bo = buffer->bo, + .offset = buffer->offset + pCreateInfo->offset, + .surface_state = anv_state_pool_alloc(&device->surface_state_pool, 64, 64), + .format = anv_format_for_vk_format(pCreateInfo->format), + .range = pCreateInfo->range, + }; - *pView = anv_buffer_view_to_handle(bview); + *view_out = view; return VK_SUCCESS; } + +VkResult anv_CreateBufferView( + VkDevice _device, + const VkBufferViewCreateInfo* pCreateInfo, + VkBufferView* pView) +{ + return driver_layer->CreateBufferView(_device, pCreateInfo, pView); +} + VkResult anv_DestroyBufferView( VkDevice _device, VkBufferView _bview) |