mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 22:38:05 +02:00
v3dv: handle texture/sampler shader state bo failure with OOM error
As we are doing this while we are creating the ImageView, we should handle it with a real error, and not an abort. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
parent
05adac2da8
commit
2894d6af9f
2 changed files with 30 additions and 18 deletions
|
|
@ -2053,17 +2053,13 @@ v3dv_CreateSampler(VkDevice _device,
|
|||
sampler->state = v3dv_bo_alloc(device, cl_packet_length(SAMPLER_STATE),
|
||||
"sampler_state");
|
||||
|
||||
if (!sampler->state) {
|
||||
fprintf(stderr, "Failed to allocate memory for sampler state\n");
|
||||
abort();
|
||||
}
|
||||
if (!sampler->state)
|
||||
goto fail_alloc;
|
||||
|
||||
bool ok = v3dv_bo_map(device, sampler->state,
|
||||
cl_packet_length(SAMPLER_STATE));
|
||||
if (!ok) {
|
||||
fprintf(stderr, "failed to map sampler state buffer\n");
|
||||
abort();
|
||||
}
|
||||
if (!ok)
|
||||
goto fail_map;
|
||||
}
|
||||
|
||||
sampler->compare_enable = pCreateInfo->compareEnable;
|
||||
|
|
@ -2072,6 +2068,12 @@ v3dv_CreateSampler(VkDevice _device,
|
|||
*pSampler = v3dv_sampler_to_handle(sampler);
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
||||
fail_map:
|
||||
v3dv_bo_free(device, sampler->state);
|
||||
fail_alloc:
|
||||
vk_free2(&device->alloc, pAllocator, sampler);
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -431,7 +431,12 @@ translate_swizzle(unsigned char pipe_swizzle)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
/*
|
||||
* Packs and ensure bo for the shader state (the latter can be temporal).
|
||||
*
|
||||
* Return false if it was not able to allocate the bo.
|
||||
*/
|
||||
static bool
|
||||
pack_texture_shader_state(struct v3dv_device *device,
|
||||
struct v3dv_image_view *image_view)
|
||||
{
|
||||
|
|
@ -443,17 +448,13 @@ pack_texture_shader_state(struct v3dv_device *device,
|
|||
v3dv_bo_alloc(device, cl_packet_length(TEXTURE_SHADER_STATE),
|
||||
"texture_shader_state");
|
||||
|
||||
if (!image_view->texture_shader_state) {
|
||||
fprintf(stderr, "Failed to allocate memory for texture shader state\n");
|
||||
abort();
|
||||
}
|
||||
if (!image_view->texture_shader_state)
|
||||
return false;
|
||||
|
||||
bool ok = v3dv_bo_map(device, image_view->texture_shader_state,
|
||||
cl_packet_length(TEXTURE_SHADER_STATE));
|
||||
if (!ok) {
|
||||
fprintf(stderr, "failed to map texture shader state\n");
|
||||
abort();
|
||||
}
|
||||
if (!ok)
|
||||
return false;
|
||||
}
|
||||
|
||||
int msaa_scale = 1; /* FIXME: hardcoded. Revisit when msaa get supported */
|
||||
|
|
@ -518,6 +519,8 @@ pack_texture_shader_state(struct v3dv_device *device,
|
|||
v3dv_layer_offset(image, 0, image_view->first_layer);
|
||||
tex.texture_base_pointer = v3dv_cl_address(NULL, base_offset);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static enum pipe_swizzle
|
||||
|
|
@ -647,11 +650,18 @@ v3dv_CreateImageView(VkDevice _device,
|
|||
|
||||
util_format_compose_swizzles(format_swizzle, image_view_swizzle, iview->swizzle);
|
||||
|
||||
pack_texture_shader_state(device, iview);
|
||||
if (!pack_texture_shader_state(device, iview))
|
||||
goto fail_texture_shader_state_alloc;
|
||||
|
||||
*pView = v3dv_image_view_to_handle(iview);
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
||||
fail_texture_shader_state_alloc:
|
||||
if (iview->texture_shader_state)
|
||||
v3dv_bo_free(device, iview->texture_shader_state);
|
||||
vk_free2(&device->alloc, pAllocator, iview);
|
||||
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue