Commit b94f3e73 authored by Luca Barbieri's avatar Luca Barbieri

nouveau: fix for gallium-resources

parent a01ff99a
......@@ -37,33 +37,42 @@ nouveau_screen_get_vendor(struct pipe_screen *pscreen)
struct nouveau_bo *
nouveau_screen_bo_new(struct pipe_screen *pscreen, unsigned alignment,
unsigned usage, unsigned size)
unsigned usage, unsigned bind, unsigned size)
{
struct nouveau_device *dev = nouveau_screen(pscreen)->device;
struct nouveau_bo *bo = NULL;
uint32_t flags = NOUVEAU_BO_MAP, tile_mode = 0, tile_flags = 0;
int ret;
if (usage & NOUVEAU_BUFFER_USAGE_TRANSFER)
/* TODO: this is somewhat wrong */
if (usage == PIPE_USAGE_STAGING)
flags |= NOUVEAU_BO_GART;
else
if (usage & NOUVEAU_BUFFER_USAGE_VERTEX) {
if (bind & PIPE_BIND_VERTEX_BUFFER) {
if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_VTXBUF))
flags |= NOUVEAU_BO_GART;
} else
if (usage & NOUVEAU_BUFFER_USAGE_INDEX) {
if (usage & PIPE_BIND_INDEX_BUFFER) {
if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF))
flags |= NOUVEAU_BO_GART;
}
if (usage & NOUVEAU_BUFFER_USAGE_PIXEL) {
if (usage & NOUVEAU_BUFFER_USAGE_TEXTURE)
if (bind & (PIPE_BIND_RENDER_TARGET |
PIPE_BIND_DEPTH_STENCIL |
PIPE_BIND_BLIT_SOURCE |
PIPE_BIND_BLIT_DESTINATION |
PIPE_BIND_SCANOUT |
PIPE_BIND_DISPLAY_TARGET |
PIPE_BIND_SAMPLER_VIEW))
{
/* TODO: this may be incorrect or suboptimal */
if (!(bind & PIPE_BIND_SCANOUT))
flags |= NOUVEAU_BO_GART;
if (!(usage & NOUVEAU_BUFFER_USAGE_CPU_READ_WRITE))
if (usage != PIPE_USAGE_DYNAMIC)
flags |= NOUVEAU_BO_VRAM;
if (dev->chipset == 0x50 || dev->chipset >= 0x80) {
if (usage & NOUVEAU_BUFFER_USAGE_ZETA)
if (bind & PIPE_BIND_DEPTH_STENCIL)
tile_flags = 0x2800;
else
tile_flags = 0x7000;
......
#ifndef __NOUVEAU_SCREEN_H__
#define __NOUVEAU_SCREEN_H__
#define PIPE_USAGE_STAGING 5
struct nouveau_screen {
struct pipe_screen base;
struct nouveau_device *device;
......@@ -21,7 +23,7 @@ nouveau_screen(struct pipe_screen *pscreen)
*/
struct nouveau_bo *
nouveau_screen_bo_new(struct pipe_screen *pscreen, unsigned alignment,
unsigned usage, unsigned size);
unsigned usage, unsigned bind, unsigned size);
struct nouveau_bo *
nouveau_screen_bo_user(struct pipe_screen *pscreen, void *ptr, unsigned bytes);
void *
......
......@@ -16,19 +16,6 @@
#define NOUVEAU_CAP_HW_VTXBUF (0xbeef0000)
#define NOUVEAU_CAP_HW_IDXBUF (0xbeef0001)
/* These were poorly defined flags at the pipe interface previously.
* They have been removed, but nouveau can continue to use its own
* versions internally:
*/
#define NOUVEAU_BUFFER_USAGE_PIXEL 0x1
#define NOUVEAU_BUFFER_USAGE_VERTEX 0x2
#define NOUVEAU_BUFFER_USAGE_CPU_READ_WRITE 0x4
#define NOUVEAU_BUFFER_USAGE_GPU_WRITE 0x8
#define NOUVEAU_BUFFER_USAGE_DISCARD 0x10
#define NOUVEAU_BUFFER_USAGE_TEXTURE 0x20
#define NOUVEAU_BUFFER_USAGE_ZETA 0x40
#define NOUVEAU_BUFFER_USAGE_TRANSFER 0x80
static inline uint32_t
nouveau_screen_transfer_flags(unsigned pipe)
{
......@@ -49,42 +36,6 @@ nouveau_screen_transfer_flags(unsigned pipe)
return flags;
}
static INLINE unsigned
nouveau_screen_bind_flags( unsigned bind )
{
unsigned buf_usage = 0;
if (bind & PIPE_BIND_VERTEX_BUFFER)
buf_usage |= NOUVEAU_BUFFER_USAGE_VERTEX;
if (bind & PIPE_BIND_INDEX_BUFFER)
buf_usage |= PIPE_BIND_INDEX_BUFFER;
if (bind & (PIPE_BIND_RENDER_TARGET |
PIPE_BIND_DEPTH_STENCIL |
PIPE_BIND_BLIT_SOURCE |
PIPE_BIND_BLIT_DESTINATION |
PIPE_BIND_SCANOUT |
PIPE_BIND_DISPLAY_TARGET |
PIPE_BIND_SAMPLER_VIEW))
buf_usage |= NOUVEAU_BUFFER_USAGE_PIXEL;
if (bind & (PIPE_BIND_TRANSFER_WRITE |
PIPE_BIND_TRANSFER_READ))
buf_usage |= NOUVEAU_BUFFER_USAGE_CPU_READ_WRITE;
/* Not sure where these two came from:
*/
if (0)
buf_usage |= NOUVEAU_BUFFER_USAGE_TRANSFER;
if (0)
buf_usage |= NOUVEAU_BUFFER_USAGE_ZETA;
return buf_usage;
}
extern struct pipe_screen *
nvfx_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
......
......@@ -100,7 +100,8 @@ nv50_buffer_create(struct pipe_screen *pscreen,
buffer->bo = nouveau_screen_bo_new(pscreen,
16,
nouveau_screen_bind_flags(buffer->base.bind),
buffer->base._usage,
buffer->base.bind,
buffer->base.width0);
if (buffer->bo == NULL)
......
......@@ -103,7 +103,8 @@ nvfx_buffer_create(struct pipe_screen *pscreen,
buffer->bo = nouveau_screen_bo_new(pscreen,
16,
nouveau_screen_bind_flags(buffer->base.bind),
buffer->base._usage,
buffer->base.bind,
buffer->base.width0);
if (buffer->bo == NULL)
......
......@@ -124,8 +124,6 @@ struct pipe_resource *
nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_resource *pt)
{
struct nvfx_miptree *mt;
unsigned buf_usage = NOUVEAU_BUFFER_USAGE_PIXEL |
NOUVEAU_BUFFER_USAGE_TEXTURE;
static int no_swizzle = -1;
if(no_swizzle < 0)
no_swizzle = debug_get_bool_option("NOUVEAU_NO_SWIZZLE", FALSE);
......@@ -179,9 +177,6 @@ nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_resource *pt)
}
}
if (pt->_usage == PIPE_USAGE_DYNAMIC)
buf_usage |= NOUVEAU_BUFFER_USAGE_CPU_READ_WRITE;
/* apparently we can't render to swizzled surfaces smaller than 64 bytes, so make them linear.
* If the user did not ask for a render target, they can still render to it, but it will cost them an extra copy.
* This also happens for small mipmaps of large textures. */
......@@ -192,7 +187,7 @@ nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_resource *pt)
nvfx_miptree_layout(mt);
mt->base.bo = nouveau_screen_bo_new(pscreen, 256,
buf_usage, mt->total_size);
pt->_usage, pt->bind, mt->total_size);
if (!mt->base.bo) {
FREE(mt);
return NULL;
......
......@@ -42,15 +42,15 @@ nvfx_resource_from_handle(struct pipe_screen * screen,
}
void
nvfx_init_resource_functions(struct pipe_context *pcontext)
nvfx_init_resource_functions(struct pipe_context *pipe)
{
pcontext->get_transfer = u_get_transfer_vtbl;
pcontext->transfer_map = u_transfer_map_vtbl;
pcontext->transfer_flush_region = u_transfer_flush_region_vtbl;
pcontext->transfer_unmap = u_transfer_unmap_vtbl;
pcontext->transfer_destroy = u_transfer_destroy_vtbl;
pcontext->transfer_inline_write = u_transfer_inline_write_vtbl;
pcontext->is_resource_referenced = nvfx_resource_is_referenced;
pipe->get_transfer = u_get_transfer_vtbl;
pipe->transfer_map = u_transfer_map_vtbl;
pipe->transfer_flush_region = u_transfer_flush_region_vtbl;
pipe->transfer_unmap = u_transfer_unmap_vtbl;
pipe->transfer_destroy = u_transfer_destroy_vtbl;
pipe->transfer_inline_write = u_transfer_inline_write_vtbl;
pipe->is_resource_referenced = nvfx_resource_is_referenced;
}
void
......
......@@ -50,7 +50,7 @@ nvfx_surface_buffer(struct pipe_surface *surf)
void
nvfx_init_resource_functions(struct pipe_context *pcontext);
nvfx_init_resource_functions(struct pipe_context *pipe);
void
nvfx_screen_init_resource_functions(struct pipe_screen *pscreen);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment