diff options
Diffstat (limited to 'src/gallium/drivers/r600/r600_screen.c')
-rw-r--r-- | src/gallium/drivers/r600/r600_screen.c | 86 |
1 files changed, 50 insertions, 36 deletions
diff --git a/src/gallium/drivers/r600/r600_screen.c b/src/gallium/drivers/r600/r600_screen.c index db17b88e9ac..9cc45761515 100644 --- a/src/gallium/drivers/r600/r600_screen.c +++ b/src/gallium/drivers/r600/r600_screen.c @@ -27,6 +27,7 @@ #include <util/u_inlines.h> #include <util/u_format.h> #include <util/u_memory.h> +#include "r600_resource.h" #include "r600_screen.h" #include "r600_texture.h" #include "r600_context.h" @@ -130,9 +131,9 @@ static boolean r600_is_format_supported(struct pipe_screen* screen, return FALSE; } switch (format) { - case PIPE_FORMAT_A4R4G4B4_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: - case PIPE_FORMAT_A1R5G5B5_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: case PIPE_FORMAT_A8_UNORM: case PIPE_FORMAT_L8_UNORM: case PIPE_FORMAT_A8R8G8B8_SRGB: @@ -141,21 +142,21 @@ static boolean r600_is_format_supported(struct pipe_screen* screen, case PIPE_FORMAT_DXT1_RGBA: case PIPE_FORMAT_DXT3_RGBA: case PIPE_FORMAT_DXT5_RGBA: - case PIPE_FORMAT_YCBCR: + case PIPE_FORMAT_UYVY: case PIPE_FORMAT_L8_SRGB: - case PIPE_FORMAT_A8L8_SRGB: - case PIPE_FORMAT_A8L8_UNORM: + case PIPE_FORMAT_L8A8_SRGB: + case PIPE_FORMAT_L8A8_UNORM: case PIPE_FORMAT_A8R8G8B8_UNORM: case PIPE_FORMAT_X8R8G8B8_UNORM: case PIPE_FORMAT_R8G8B8A8_UNORM: case PIPE_FORMAT_R8G8B8X8_UNORM: case PIPE_FORMAT_I8_UNORM: case PIPE_FORMAT_Z16_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_Z32_UNORM: - case PIPE_FORMAT_S8Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + case PIPE_FORMAT_Z32_UNORM: + case PIPE_FORMAT_Z24_UNORM_S8_USCALED: + case PIPE_FORMAT_Z24X8_UNORM: return TRUE; default: /* Unknown format... */ @@ -164,13 +165,11 @@ static boolean r600_is_format_supported(struct pipe_screen* screen, return FALSE; } -static struct pipe_transfer* r600_get_tex_transfer(struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned face, unsigned level, - unsigned zslice, - enum pipe_transfer_usage usage, - unsigned x, unsigned y, - unsigned w, unsigned h) +struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx, + struct pipe_resource *texture, + struct pipe_subresource sr, + unsigned usage, + const struct pipe_box *box) { struct r600_texture *rtex = (struct r600_texture*)texture; struct r600_transfer *trans; @@ -178,31 +177,50 @@ static struct pipe_transfer* r600_get_tex_transfer(struct pipe_screen *screen, trans = CALLOC_STRUCT(r600_transfer); if (trans == NULL) return NULL; - pipe_texture_reference(&trans->transfer.texture, texture); - trans->transfer.x = x; - trans->transfer.y = y; - trans->transfer.width = w; - trans->transfer.height = h; - trans->transfer.stride = rtex->stride[level]; + pipe_resource_reference(&trans->transfer.resource, texture); + trans->transfer.sr = sr; trans->transfer.usage = usage; - trans->transfer.zslice = zslice; - trans->transfer.face = face; - trans->offset = r600_texture_get_offset(rtex, level, zslice, face); + trans->transfer.box = *box; + trans->transfer.stride = rtex->stride[sr.level]; + trans->offset = r600_texture_get_offset(rtex, sr.level, box->z, sr.face); return &trans->transfer; } -static void r600_tex_transfer_destroy(struct pipe_transfer *trans) +void r600_texture_transfer_destroy(struct pipe_context *ctx, + struct pipe_transfer *trans) { + pipe_resource_reference(&trans->resource, NULL); + FREE(trans); } -static void* r600_transfer_map(struct pipe_screen* screen, struct pipe_transfer* transfer) +void* r600_texture_transfer_map(struct pipe_context *ctx, + struct pipe_transfer* transfer) { - /* FIXME implement */ - return NULL; + struct r600_transfer *rtransfer = (struct r600_transfer*)transfer; + struct r600_texture *rtex = (struct r600_texture*)transfer->resource; + char *map; + enum pipe_format format = rtex->b.b.format; + + map = pipe_buffer_map(ctx, rtex->buffer, + transfer->usage, + &rtransfer->buffer_transfer); + + if (!map) { + return NULL; + } + + return map + rtransfer->offset + + transfer->box.y / util_format_get_blockheight(format) * transfer->stride + + transfer->box.x / util_format_get_blockwidth(format) * util_format_get_blocksize(format); } -static void r600_transfer_unmap(struct pipe_screen* screen, struct pipe_transfer* transfer) +void r600_texture_transfer_unmap(struct pipe_context *ctx, + struct pipe_transfer* transfer) { + struct r600_transfer *rtransfer = (struct r600_transfer*)transfer; + struct r600_texture *rtex = (struct r600_texture*)transfer->resource; + + pipe_buffer_unmap(ctx, rtex->buffer, rtransfer->buffer_transfer); } static void r600_destroy_screen(struct pipe_screen* pscreen) @@ -231,11 +249,7 @@ struct pipe_screen *radeon_create_screen(struct radeon *rw) rscreen->screen.get_paramf = r600_get_paramf; rscreen->screen.is_format_supported = r600_is_format_supported; rscreen->screen.context_create = r600_create_context; - rscreen->screen.get_tex_transfer = r600_get_tex_transfer; - rscreen->screen.tex_transfer_destroy = r600_tex_transfer_destroy; - rscreen->screen.transfer_map = r600_transfer_map; - rscreen->screen.transfer_unmap = r600_transfer_unmap; - r600_screen_init_buffer_functions(&rscreen->screen); r600_init_screen_texture_functions(&rscreen->screen); + r600_init_screen_resource_functions(rscreen); return &rscreen->screen; } |