summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/drivers/llvmpipe/lp_scene.c
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2023-11-02 04:53:47 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2023-11-02 04:53:47 +0000
commitb44518130b33cadb5c1d619e9e936ae0e0dbf7cb (patch)
tree6069eb03c39fbc79808a7d94f857118cce75cbe3 /lib/mesa/src/gallium/drivers/llvmpipe/lp_scene.c
parent32aeb3c41fedbbd7b11aacfec48e8f699d16bff0 (diff)
Merge Mesa 23.1.9
Diffstat (limited to 'lib/mesa/src/gallium/drivers/llvmpipe/lp_scene.c')
-rw-r--r--lib/mesa/src/gallium/drivers/llvmpipe/lp_scene.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/lib/mesa/src/gallium/drivers/llvmpipe/lp_scene.c b/lib/mesa/src/gallium/drivers/llvmpipe/lp_scene.c
index 7ad04fe10..9b2f84824 100644
--- a/lib/mesa/src/gallium/drivers/llvmpipe/lp_scene.c
+++ b/lib/mesa/src/gallium/drivers/llvmpipe/lp_scene.c
@@ -199,7 +199,7 @@ lp_scene_begin_rasterization(struct lp_scene *scene)
{
const struct pipe_framebuffer_state *fb = &scene->fb;
- //LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
+ //LP_DBG(DEBUG_RAST, "%s\n", __func__);
for (unsigned i = 0; i < scene->fb.nr_cbufs; i++) {
struct pipe_surface *cbuf = scene->fb.cbufs[i];
@@ -219,10 +219,10 @@ lp_scene_begin_rasterization(struct lp_scene *scene)
void
lp_scene_end_rasterization(struct lp_scene *scene)
{
- int i;
+ mtx_lock(&scene->mutex);
/* Unmap color buffers */
- for (i = 0; i < scene->fb.nr_cbufs; i++) {
+ for (unsigned i = 0; i < scene->fb.nr_cbufs; i++) {
if (scene->cbufs[i].map) {
struct pipe_surface *cbuf = scene->fb.cbufs[i];
if (llvmpipe_resource_is_texture(cbuf->texture)) {
@@ -290,7 +290,7 @@ lp_scene_end_rasterization(struct lp_scene *scene)
*/
j = 0;
for (struct shader_ref *ref = scene->frag_shaders; ref; ref = ref->next) {
- for (i = 0; i < ref->count; i++) {
+ for (int i = 0; i < ref->count; i++) {
if (LP_DEBUG & DEBUG_SETUP)
debug_printf("shader %d: %p\n", j, (void *) ref->variant[i]);
j++;
@@ -326,6 +326,8 @@ lp_scene_end_rasterization(struct lp_scene *scene)
scene->alloc_failed = FALSE;
util_unreference_framebuffer_state(&scene->fb);
+
+ mtx_unlock(&scene->mutex);
}
@@ -354,7 +356,7 @@ struct data_block *
lp_scene_new_data_block(struct lp_scene *scene)
{
if (scene->scene_size + DATA_BLOCK_SIZE > LP_SCENE_MAX_SIZE) {
- if (0) debug_printf("%s: failed\n", __FUNCTION__);
+ if (0) debug_printf("%s: failed\n", __func__);
scene->alloc_failed = TRUE;
return NULL;
} else {
@@ -404,6 +406,8 @@ lp_scene_add_resource_reference(struct lp_scene *scene,
struct resource_ref **list = writeable ? &scene->writeable_resources : &scene->resources;
struct resource_ref **last = list;
+ mtx_lock(&scene->mutex);
+
/* Look at existing resource blocks:
*/
for (ref = *list; ref; ref = ref->next) {
@@ -412,8 +416,10 @@ lp_scene_add_resource_reference(struct lp_scene *scene,
/* Search for this resource:
*/
for (i = 0; i < ref->count; i++)
- if (ref->resource[i] == resource)
+ if (ref->resource[i] == resource) {
+ mtx_unlock(&scene->mutex);
return TRUE;
+ }
if (ref->count < RESOURCE_REF_SZ) {
/* If the block is half-empty, then append the reference here.
@@ -427,8 +433,10 @@ lp_scene_add_resource_reference(struct lp_scene *scene,
if (!ref) {
assert(*last == NULL);
*last = lp_scene_alloc(scene, sizeof *ref);
- if (*last == NULL)
+ if (*last == NULL) {
+ mtx_unlock(&scene->mutex);
return FALSE;
+ }
ref = *last;
memset(ref, 0, sizeof *ref);
@@ -450,14 +458,11 @@ lp_scene_add_resource_reference(struct lp_scene *scene,
* next resource added which exceeds 64MB in referenced texture
* data.
*/
- if (!initializing_scene &&
- scene->resource_reference_size >= LP_SCENE_MAX_RESOURCE_SIZE)
- return FALSE;
-
- return TRUE;
+ int flush = (initializing_scene || scene->resource_reference_size < LP_SCENE_MAX_RESOURCE_SIZE);
+ mtx_unlock(&scene->mutex);
+ return flush;
}
-
/**
* Add a reference to a fragment shader variant
* Return FALSE if out of memory, TRUE otherwise.
@@ -517,6 +522,15 @@ lp_scene_is_resource_referenced(const struct lp_scene *scene,
{
const struct resource_ref *ref;
+ /* check the render targets */
+ for (unsigned j = 0; j < scene->fb.nr_cbufs; j++) {
+ if (scene->fb.cbufs[j] && scene->fb.cbufs[j]->texture == resource)
+ return LP_REFERENCED_FOR_READ | LP_REFERENCED_FOR_WRITE;
+ }
+ if (scene->fb.zsbuf && scene->fb.zsbuf->texture == resource) {
+ return LP_REFERENCED_FOR_READ | LP_REFERENCED_FOR_WRITE;
+ }
+
for (ref = scene->resources; ref; ref = ref->next) {
for (int i = 0; i < ref->count; i++)
if (ref->resource[i] == resource)