lavapipe: move noop fs creation to device

this avoids creating a separate noop fs for every pipeline

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21051>
This commit is contained in:
Mike Blumenkrantz 2023-02-01 09:58:33 -05:00 committed by Marge Bot
parent dc7f6c5324
commit 453f49ce6d
3 changed files with 15 additions and 10 deletions

View file

@ -42,6 +42,8 @@
#include "util/u_atomic.h"
#include "util/timespec.h"
#include "util/ptralloc.h"
#include "nir.h"
#include "nir_builder.h"
#if defined(VK_USE_PLATFORM_WAYLAND_KHR) || \
defined(VK_USE_PLATFORM_WIN32_KHR) || \
@ -1632,6 +1634,12 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_CreateDevice(
return result;
}
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_FRAGMENT, NULL, "dummy_frag");
struct pipe_shader_state shstate = {0};
shstate.type = PIPE_SHADER_IR_NIR;
shstate.ir.nir = b.shader;
device->noop_fs = device->queue.ctx->create_fs_state(device->queue.ctx, &shstate);
*pDevice = lvp_device_to_handle(device);
return VK_SUCCESS;
@ -1644,6 +1652,8 @@ VKAPI_ATTR void VKAPI_CALL lvp_DestroyDevice(
{
LVP_FROM_HANDLE(lvp_device, device, _device);
device->queue.ctx->delete_fs_state(device->queue.ctx, device->noop_fs);
if (device->queue.last_fence)
device->pscreen->fence_reference(device->pscreen, &device->queue.last_fence, NULL);
lvp_queue_finish(&device->queue);

View file

@ -44,7 +44,7 @@ lvp_pipeline_destroy(struct lvp_device *device, struct lvp_pipeline *pipeline)
{
if (pipeline->shader_cso[PIPE_SHADER_VERTEX])
device->queue.ctx->delete_vs_state(device->queue.ctx, pipeline->shader_cso[PIPE_SHADER_VERTEX]);
if (pipeline->shader_cso[PIPE_SHADER_FRAGMENT])
if (pipeline->shader_cso[PIPE_SHADER_FRAGMENT] && !pipeline->noop_fs)
device->queue.ctx->delete_fs_state(device->queue.ctx, pipeline->shader_cso[PIPE_SHADER_FRAGMENT]);
if (pipeline->shader_cso[PIPE_SHADER_GEOMETRY])
device->queue.ctx->delete_gs_state(device->queue.ctx, pipeline->shader_cso[PIPE_SHADER_GEOMETRY]);
@ -888,15 +888,8 @@ lvp_graphics_pipeline_init(struct lvp_pipeline *pipeline,
}
if (has_fragment_shader == false) {
/* create a dummy fragment shader for this pipeline. */
nir_builder b = nir_builder_init_simple_shader(MESA_SHADER_FRAGMENT, NULL,
"dummy_frag");
pipeline->pipeline_nir[MESA_SHADER_FRAGMENT] = b.shader;
struct pipe_shader_state shstate = {0};
shstate.type = PIPE_SHADER_IR_NIR;
shstate.ir.nir = nir_shader_clone(NULL, pipeline->pipeline_nir[MESA_SHADER_FRAGMENT]);
pipeline->shader_cso[PIPE_SHADER_FRAGMENT] = device->queue.ctx->create_fs_state(device->queue.ctx, &shstate);
pipeline->noop_fs = true;
pipeline->shader_cso[PIPE_SHADER_FRAGMENT] = device->noop_fs;
}
}
return VK_SUCCESS;

View file

@ -179,6 +179,7 @@ struct lvp_device {
struct lvp_instance * instance;
struct lvp_physical_device *physical_device;
struct pipe_screen *pscreen;
void *noop_fs;
bool poison_mem;
};
@ -433,6 +434,7 @@ struct lvp_pipeline {
bool line_rectangular;
bool gs_output_lines;
bool library;
bool noop_fs;
};
struct lvp_event {