diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index 5be730ebf88..07a5c26785f 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -821,17 +821,18 @@ submit_queue(void *data, void *gdata, int thread_index) const bool screen_lost = screen->device_lost && keep_promises; bool recorded = !screen_lost; if (recorded && bs->has_work) { - VRAM_ALLOC_LOOP(result, - VKSCR(EndCommandBuffer)(bs->cmdbuf), - if (result != VK_SUCCESS) { - mesa_loge("ZINK: vkEndCommandBuffer failed (%s)", vk_Result_to_str(result)); - recorded = false; - if (!keep_promises) { - bs->is_device_lost = true; - goto end; - } + /* Once, not in VRAM_ALLOC_LOOP: a failed vkEndCommandBuffer leaves the command buffer invalid (the + * error is its recording's, e.g. a pipeline the driver could not create), and ending it again is + * invalid usage that the runtime asserts on. */ + result = VKSCR(EndCommandBuffer)(bs->cmdbuf); + if (result != VK_SUCCESS) { + mesa_loge("ZINK: vkEndCommandBuffer failed (%s)", vk_Result_to_str(result)); + recorded = false; + if (!keep_promises) { + bs->is_device_lost = true; + goto end; } - ); + } } if (recorded && bs->has_reordered_work) { VkMemoryBarrier mb; @@ -846,38 +847,35 @@ submit_queue(void *data, void *gdata, int thread_index) src, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 1, &mb, 0, NULL, 0, NULL); - VRAM_ALLOC_LOOP(result, - VKSCR(EndCommandBuffer)(bs->reordered_cmdbuf), - if (result != VK_SUCCESS) { - mesa_loge("ZINK: vkEndCommandBuffer failed (%s)", vk_Result_to_str(result)); - recorded = false; - if (!keep_promises) { - bs->is_device_lost = true; - goto end; - } + result = VKSCR(EndCommandBuffer)(bs->reordered_cmdbuf); /* once: see above */ + if (result != VK_SUCCESS) { + mesa_loge("ZINK: vkEndCommandBuffer failed (%s)", vk_Result_to_str(result)); + recorded = false; + if (!keep_promises) { + bs->is_device_lost = true; + goto end; } - ); + } } if (recorded && bs->has_unsync) { - VRAM_ALLOC_LOOP(result, - VKSCR(EndCommandBuffer)(bs->unsynchronized_cmdbuf), - if (result != VK_SUCCESS) { - mesa_loge("ZINK: vkEndCommandBuffer failed (%s)", vk_Result_to_str(result)); - recorded = false; - if (!keep_promises) { - bs->is_device_lost = true; - goto end; - } + result = VKSCR(EndCommandBuffer)(bs->unsynchronized_cmdbuf); /* once: see above */ + if (result != VK_SUCCESS) { + mesa_loge("ZINK: vkEndCommandBuffer failed (%s)", vk_Result_to_str(result)); + recorded = false; + if (!keep_promises) { + bs->is_device_lost = true; + goto end; } - ); + } } if (!recorded) { - /* the batch that lost the screen reports it (post_submit); later ones only keep their promises */ - if (!screen_lost) { - mesa_loge("ZINK: batch %" PRIu64 " dropped: its semaphores are signalled without its command buffers; " - "the context is lost", batch_id); - bs->is_device_lost = true; - } + /* The batch that lost the screen reports it (post_submit); later ones only keep their promises. A batch + * whose recording failed (vkEndCommandBuffer's error: a render or draw the driver refused) is dropped + * without losing the context: its work is missing, the device and the context's other work are not, + * and losing the context would fail everything after it. */ + if (!screen_lost) + mesa_loge("ZINK: batch %" PRIu64 " dropped: its recording failed; its semaphores are signalled " + "without its command buffers", batch_id); si[ZINK_SUBMIT_CMDBUF].commandBufferCount = 0; } diff --git a/src/mesa/state_tracker/st_cb_copyimage.c b/src/mesa/state_tracker/st_cb_copyimage.c index f821ce7932d..86ca9d11403 100644 --- a/src/mesa/state_tracker/st_cb_copyimage.c +++ b/src/mesa/state_tracker/st_cb_copyimage.c @@ -138,6 +138,14 @@ get_canonical_format(struct pipe_screen *screen, break; case 16: + /* UNORM for G16R16's sake, but a driver that cannot both render + * and sample R16G16_UNORM (a GLES driver need not: it is not a + * core format) copies R16G16 bit-exactly as UINT. + */ + if (desc->swizzle[0] == PIPE_SWIZZLE_X && desc->swizzle[1] == PIPE_SWIZZLE_Y && + !screen->is_format_supported(screen, PIPE_FORMAT_R16G16_UNORM, PIPE_TEXTURE_2D, 0, 0, + PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW)) + return PIPE_FORMAT_R16G16_UINT; RETURN_FOR_SWIZZLE2(X, Y, PIPE_FORMAT_R16G16_UNORM); RETURN_FOR_SWIZZLE2(Y, X, PIPE_FORMAT_G16R16_UNORM); break; diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index e9a4e1ffc33..c36caa4f3e4 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -1460,6 +1460,15 @@ void st_init_extensions(struct pipe_screen *screen, get_max_samples_for_formats(screen, ARRAY_SIZE(int_formats), int_formats, consts->MaxSamples, PIPE_BIND_SAMPLER_VIEW); + /* GL's minimum is 1: a driver without multisampled integer formats + * still has single-sampled ones (ES 3.1 queries it per format) + */ + if (consts->MaxSamples && !consts->MaxIntegerSamples) + consts->MaxIntegerSamples = 1; + if (consts->MaxSamples && !consts->MaxColorTextureSamples) + consts->MaxColorTextureSamples = 1; + if (consts->MaxSamples && !consts->MaxDepthTextureSamples) + consts->MaxDepthTextureSamples = 1; /* ARB_framebuffer_no_attachments, assume max no. of samples 32 */ consts->MaxFramebufferSamples =