gallium: fix some surface usage bugs
When a surface is created with GPU_WRITE that really means "GPU render" and that can involve reads (blending). Set surface usage to PIPE_BUFFER_USAGE_CPU_READ + WRITE. Fixes progs/demos/lodbias demo. Also, mark texture as 'modified' when mapped for writing so that the tile cache can know when to freshen a cached tile. Fixes glTexSubImage2D().
This commit is contained in:
@@ -207,12 +207,19 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
|
|||||||
* done with the CPU. Let's adjust the flags to take that into
|
* done with the CPU. Let's adjust the flags to take that into
|
||||||
* account.
|
* account.
|
||||||
*/
|
*/
|
||||||
if (ps->usage & PIPE_BUFFER_USAGE_GPU_WRITE)
|
if (ps->usage & PIPE_BUFFER_USAGE_GPU_WRITE) {
|
||||||
ps->usage |= PIPE_BUFFER_USAGE_CPU_WRITE;
|
/* GPU_WRITE means "render" and that can involve reads (blending) */
|
||||||
|
ps->usage |= PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_CPU_READ;
|
||||||
|
}
|
||||||
|
|
||||||
if (ps->usage & PIPE_BUFFER_USAGE_GPU_READ)
|
if (ps->usage & PIPE_BUFFER_USAGE_GPU_READ)
|
||||||
ps->usage |= PIPE_BUFFER_USAGE_CPU_READ;
|
ps->usage |= PIPE_BUFFER_USAGE_CPU_READ;
|
||||||
|
|
||||||
|
if (ps->usage & (PIPE_BUFFER_USAGE_CPU_WRITE |
|
||||||
|
PIPE_BUFFER_USAGE_GPU_WRITE)) {
|
||||||
|
/* Mark the surface as dirty. The tile cache will look for this. */
|
||||||
|
spt->modified = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
pipe_texture_reference(&ps->texture, pt);
|
pipe_texture_reference(&ps->texture, pt);
|
||||||
ps->face = face;
|
ps->face = face;
|
||||||
|
@@ -47,6 +47,8 @@ struct softpipe_texture
|
|||||||
/* The data is held here:
|
/* The data is held here:
|
||||||
*/
|
*/
|
||||||
struct pipe_buffer *buffer;
|
struct pipe_buffer *buffer;
|
||||||
|
|
||||||
|
boolean modified;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -37,6 +37,7 @@
|
|||||||
#include "util/p_tile.h"
|
#include "util/p_tile.h"
|
||||||
#include "sp_context.h"
|
#include "sp_context.h"
|
||||||
#include "sp_surface.h"
|
#include "sp_surface.h"
|
||||||
|
#include "sp_texture.h"
|
||||||
#include "sp_tile_cache.h"
|
#include "sp_tile_cache.h"
|
||||||
|
|
||||||
#define NUM_ENTRIES 32
|
#define NUM_ENTRIES 32
|
||||||
@@ -506,6 +507,15 @@ sp_get_cached_tile_tex(struct pipe_context *pipe,
|
|||||||
face, level);
|
face, level);
|
||||||
struct softpipe_cached_tile *tile = tc->entries + pos;
|
struct softpipe_cached_tile *tile = tc->entries + pos;
|
||||||
|
|
||||||
|
if (tc->texture) {
|
||||||
|
struct softpipe_texture *spt = softpipe_texture(tc->texture);
|
||||||
|
if (spt->modified) {
|
||||||
|
/* texture was modified, force a cache reload */
|
||||||
|
tile->x = -1;
|
||||||
|
spt->modified = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tile_x != tile->x ||
|
if (tile_x != tile->x ||
|
||||||
tile_y != tile->y ||
|
tile_y != tile->y ||
|
||||||
z != tile->z ||
|
z != tile->z ||
|
||||||
|
Reference in New Issue
Block a user