Quellcode durchsuchen

cell: attempt to convert to pipe_resources

Can't even compile test this driver.
gallium-resources
Keith Whitwell vor 15 Jahren
Ursprung
Commit
f29ac73f3f

+ 0
- 1
src/gallium/drivers/cell/ppu/Makefile Datei anzeigen

@@ -21,7 +21,6 @@ SPU_CODE_MODULE = ../spu/g3d_spu.a

SOURCES = \
cell_batch.c \
cell_buffer.c \
cell_clear.c \
cell_context.c \
cell_draw_arrays.c \

+ 0
- 118
src/gallium/drivers/cell/ppu/cell_buffer.c Datei anzeigen

@@ -1,118 +0,0 @@
/**************************************************************************
*
* Copyright 2009 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/


#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_math.h"

#include "cell_screen.h"
#include "cell_buffer.h"


static void *
cell_buffer_map(struct pipe_screen *screen,
struct pipe_buffer *buf,
unsigned flags)
{
struct cell_buffer *cell_buf = cell_buffer(buf);
return cell_buf->data;
}


static void
cell_buffer_unmap(struct pipe_screen *screen,
struct pipe_buffer *buf)
{
}


static void
cell_buffer_destroy(struct pipe_buffer *buf)
{
struct cell_buffer *sbuf = cell_buffer(buf);

if (!sbuf->userBuffer)
align_free(sbuf->data);
FREE(sbuf);
}


static struct pipe_buffer *
cell_buffer_create(struct pipe_screen *screen,
unsigned alignment,
unsigned usage,
unsigned size)
{
struct cell_buffer *buffer = CALLOC_STRUCT(cell_buffer);

pipe_reference_init(&buffer->base.reference, 1);
buffer->base.screen = screen;
buffer->base.alignment = MAX2(alignment, 16);
buffer->base.usage = usage;
buffer->base.size = size;

buffer->data = align_malloc(size, alignment);

return &buffer->base;
}


/**
* Create buffer which wraps user-space data.
*/
static struct pipe_buffer *
cell_user_buffer_create(struct pipe_screen *screen,
void *ptr,
unsigned bytes)
{
struct cell_buffer *buffer;

buffer = CALLOC_STRUCT(cell_buffer);
if(!buffer)
return NULL;

pipe_reference_init(&buffer->base.reference, 1);
buffer->base.screen = screen;
buffer->base.size = bytes;
buffer->userBuffer = TRUE;
buffer->data = ptr;

return &buffer->base;
}


void
cell_init_screen_buffer_funcs(struct pipe_screen *screen)
{
screen->buffer_create = cell_buffer_create;
screen->user_buffer_create = cell_user_buffer_create;
screen->buffer_map = cell_buffer_map;
screen->buffer_unmap = cell_buffer_unmap;
screen->buffer_destroy = cell_buffer_destroy;
}

+ 0
- 55
src/gallium/drivers/cell/ppu/cell_buffer.h Datei anzeigen

@@ -1,55 +0,0 @@
/**************************************************************************
*
* Copyright 2009 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/

#ifndef SP_BUFFER_H
#define SP_BUFFER_H

#include "pipe/p_compiler.h"
#include "pipe/p_state.h"


struct cell_buffer
{
struct pipe_buffer base;
boolean userBuffer; /** Is this a user-space buffer? */
void *data;
};


/** Cast wrapper */
static INLINE struct cell_buffer *
cell_buffer( struct pipe_buffer *buf )
{
return (struct cell_buffer *)buf;
}


void
cell_init_screen_buffer_funcs(struct pipe_screen *screen);


#endif /* SP_BUFFER_H */

+ 3
- 14
src/gallium/drivers/cell/ppu/cell_context.c Datei anzeigen

@@ -99,8 +99,8 @@ static const struct debug_named_value cell_debug_flags[] = {
};

static unsigned int
cell_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
cell_is_resource_referenced( struct pipe_context *pipe,
struct pipe_resource *texture,
unsigned face, unsigned level)
{
/**
@@ -110,16 +110,6 @@ cell_is_texture_referenced( struct pipe_context *pipe,
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}

static unsigned int
cell_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
/**
* FIXME: Optimize.
*/

return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}

struct pipe_context *
cell_create_context(struct pipe_screen *screen,
@@ -144,8 +134,7 @@ cell_create_context(struct pipe_screen *screen,
cell->pipe.clear = cell_clear;
cell->pipe.flush = cell_flush;

cell->pipe.is_texture_referenced = cell_is_texture_referenced;
cell->pipe.is_buffer_referenced = cell_is_buffer_referenced;
cell->pipe.is_resource_referenced = cell_is_resource_referenced;

#if 0
cell->pipe.begin_query = cell_begin_query;

+ 2
- 2
src/gallium/drivers/cell/ppu/cell_context.h Datei anzeigen

@@ -122,11 +122,11 @@ struct cell_context
struct pipe_blend_color blend_color;
struct pipe_stencil_ref stencil_ref;
struct pipe_clip_state clip;
struct pipe_buffer *constants[2];
struct pipe_resource *constants[2];
struct pipe_framebuffer_state framebuffer;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
struct cell_texture *texture[PIPE_MAX_SAMPLERS];
struct cell_resource *texture[PIPE_MAX_SAMPLERS];
struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
uint num_textures;
struct pipe_viewport_state viewport;

+ 5
- 5
src/gallium/drivers/cell/ppu/cell_draw_arrays.c Datei anzeigen

@@ -39,7 +39,7 @@
#include "cell_draw_arrays.h"
#include "cell_state.h"
#include "cell_flush.h"
#include "cell_buffer.h"
#include "cell_texture.h"

#include "draw/draw_context.h"

@@ -57,7 +57,7 @@
*/
static void
cell_draw_range_elements(struct pipe_context *pipe,
struct pipe_buffer *indexBuffer,
struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned min_index,
unsigned max_index,
@@ -78,12 +78,12 @@ cell_draw_range_elements(struct pipe_context *pipe,
* Map vertex buffers
*/
for (i = 0; i < cell->num_vertex_buffers; i++) {
void *buf = cell_buffer(cell->vertex_buffer[i].buffer)->data;
void *buf = cell_resource(cell->vertex_buffer[i].buffer)->data;
draw_set_mapped_vertex_buffer(draw, i, buf);
}
/* Map index buffer, if present */
if (indexBuffer) {
void *mapped_indexes = cell_buffer(indexBuffer)->data;
void *mapped_indexes = cell_resource(indexBuffer)->data;
draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
}
else {
@@ -116,7 +116,7 @@ cell_draw_range_elements(struct pipe_context *pipe,

static void
cell_draw_elements(struct pipe_context *pipe,
struct pipe_buffer *indexBuffer,
struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count)
{

+ 5
- 5
src/gallium/drivers/cell/ppu/cell_fence.c Datei anzeigen

@@ -82,7 +82,7 @@ cell_fence_finish(const struct cell_context *cell,

struct cell_buffer_node
{
struct pipe_buffer *buffer;
struct pipe_resource *buffer;
struct cell_buffer_node *next;
};

@@ -90,12 +90,12 @@ struct cell_buffer_node
static void
cell_add_buffer_to_list(struct cell_context *cell,
struct cell_buffer_list *list,
struct pipe_buffer *buffer)
struct pipe_resource *buffer)
{
struct cell_buffer_node *node = CALLOC_STRUCT(cell_buffer_node);
/* create new list node which references the buffer, insert at head */
if (node) {
pipe_buffer_reference(&node->buffer, buffer);
pipe_resource_reference(&node->buffer, buffer);
node->next = list->head;
list->head = node;
}
@@ -129,7 +129,7 @@ cell_free_fenced_buffers(struct cell_context *cell,
if (node->buffer->reference.count == 1)
printf(" Delete!\n");
#endif
pipe_buffer_reference(&node->buffer, NULL);
pipe_resource_reference(&node->buffer, NULL);
FREE(node);
node = next;
}
@@ -150,7 +150,7 @@ cell_add_fenced_textures(struct cell_context *cell)
uint i;

for (i = 0; i < cell->num_textures; i++) {
struct cell_texture *ct = cell->texture[i];
struct cell_resource *ct = cell->texture[i];
if (ct) {
#if 0
printf("Adding texture %p buffer %p to list\n",

+ 10
- 10
src/gallium/drivers/cell/ppu/cell_pipe_state.c Datei anzeigen

@@ -271,12 +271,12 @@ cell_set_fragment_sampler_views(struct pipe_context *pipe,
struct pipe_sampler_view *old_view = cell->fragment_sampler_views[i];

if (old_view != new_view) {
struct pipe_texture *new_tex = new_view ? new_view->texture : NULL;
struct pipe_resource *new_tex = new_view ? new_view->texture : NULL;

pipe_sampler_view_reference(&cell->fragment_sampler_views[i],
views[i]);
pipe_texture_reference((struct pipe_texture **) &cell->texture[i],
(struct pipe_texture *) new_tex);
pipe_resource_reference((struct pipe_resource **) &cell->texture[i],
(struct pipe_resource *) new_tex);

changed |= (1 << i);
}
@@ -293,7 +293,7 @@ cell_set_fragment_sampler_views(struct pipe_context *pipe,

static struct pipe_sampler_view *
cell_create_sampler_view(struct pipe_context *pipe,
struct pipe_texture *texture,
struct pipe_resource *texture,
const struct pipe_sampler_view *templ)
{
struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
@@ -302,7 +302,7 @@ cell_create_sampler_view(struct pipe_context *pipe,
*view = *templ;
view->reference.count = 1;
view->texture = NULL;
pipe_texture_reference(&view->texture, texture);
pipe_resource_reference(&view->texture, texture);
view->context = pipe;
}

@@ -314,7 +314,7 @@ static void
cell_sampler_view_destroy(struct pipe_context *pipe,
struct pipe_sampler_view *view)
{
pipe_texture_reference(&view->texture, NULL);
pipe_resource_reference(&view->texture, NULL);
FREE(view);
}

@@ -333,7 +333,7 @@ cell_map_surfaces(struct cell_context *cell)
for (i = 0; i < 1; i++) {
struct pipe_surface *ps = cell->framebuffer.cbufs[i];
if (ps) {
struct cell_texture *ct = cell_texture(ps->texture);
struct cell_resource *ct = cell_resource(ps->texture);
#if 0
cell->cbuf_map[i] = screen->buffer_map(screen,
ct->buffer,
@@ -348,7 +348,7 @@ cell_map_surfaces(struct cell_context *cell)
{
struct pipe_surface *ps = cell->framebuffer.zsbuf;
if (ps) {
struct cell_texture *ct = cell_texture(ps->texture);
struct cell_resource *ct = cell_resource(ps->texture);
#if 0
cell->zsbuf_map = screen->buffer_map(screen,
ct->buffer,
@@ -374,7 +374,7 @@ cell_unmap_surfaces(struct cell_context *cell)
for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
struct pipe_surface *ps = cell->framebuffer.cbufs[i];
if (ps && cell->cbuf_map[i]) {
/*struct cell_texture *ct = cell_texture(ps->texture);*/
/*struct cell_resource *ct = cell_resource(ps->texture);*/
assert(ps->texture);
/*assert(ct->buffer);*/

@@ -386,7 +386,7 @@ cell_unmap_surfaces(struct cell_context *cell)
{
struct pipe_surface *ps = cell->framebuffer.zsbuf;
if (ps && cell->zsbuf_map) {
/*struct cell_texture *ct = cell_texture(ps->texture);*/
/*struct cell_resource *ct = cell_resource(ps->texture);*/
/*screen->buffer_unmap(screen, ct->buffer);*/
cell->zsbuf_map = NULL;
}

+ 0
- 2
src/gallium/drivers/cell/ppu/cell_screen.c Datei anzeigen

@@ -35,7 +35,6 @@
#include "cell_context.h"
#include "cell_screen.h"
#include "cell_texture.h"
#include "cell_buffer.h"
#include "cell_public.h"

#include "state_tracker/sw_winsys.h"
@@ -195,7 +194,6 @@ cell_create_screen(struct sw_winsys *winsys)
screen->base.context_create = cell_create_context;

cell_init_screen_texture_funcs(&screen->base);
cell_init_screen_buffer_funcs(&screen->base);

return &screen->base;
}

+ 2
- 2
src/gallium/drivers/cell/ppu/cell_state_emit.c Datei anzeigen

@@ -241,7 +241,7 @@ cell_emit_state(struct cell_context *cell)

if (cell->dirty & (CELL_NEW_FS_CONSTANTS)) {
const uint shader = PIPE_SHADER_FRAGMENT;
const uint num_const = cell->constants[shader]->size / sizeof(float);
const uint num_const = cell->constants[shader]->width0 / sizeof(float);
uint i, j;
float *buf = cell_batch_alloc16(cell, ROUNDUP16(32 + num_const * sizeof(float)));
uint32_t *ibuf = (uint32_t *) buf;
@@ -293,7 +293,7 @@ cell_emit_state(struct cell_context *cell)
texture->opcode[0] = CELL_CMD_STATE_TEXTURE;
texture->unit = i;
if (cell->texture[i]) {
struct cell_texture *ct = cell->texture[i];
struct cell_resource *ct = cell->texture[i];
uint level;
for (level = 0; level < CELL_MAX_TEXTURE_LEVELS; level++) {
texture->start[level] = (ct->mapped +

+ 5
- 5
src/gallium/drivers/cell/ppu/cell_state_shader.c Datei anzeigen

@@ -34,7 +34,7 @@
#include "cell_context.h"
#include "cell_state.h"
#include "cell_gen_fp.h"
#include "cell_buffer.h"
#include "cell_texture.h"


/** cast wrapper */
@@ -183,11 +183,11 @@ cell_delete_vs_state(struct pipe_context *pipe, void *vs)
static void
cell_set_constant_buffer(struct pipe_context *pipe,
uint shader, uint index,
struct pipe_buffer *constants)
struct pipe_resource *constants)
{
struct cell_context *cell = cell_context(pipe);
unsigned size = constants ? constants->size : 0;
const void *data = constants ? cell_buffer(constants)->data : NULL;
unsigned size = constants ? constants->width0 : 0;
const void *data = constants ? cell_resource(constants)->data : NULL;

assert(shader < PIPE_SHADER_TYPES);
assert(index == 0);
@@ -198,7 +198,7 @@ cell_set_constant_buffer(struct pipe_context *pipe,
draw_flush(cell->draw);

/* note: reference counting */
pipe_buffer_reference(&cell->constants[shader], constants);
pipe_resource_reference(&cell->constants[shader], constants);

if(shader == PIPE_SHADER_VERTEX) {
draw_set_mapped_constant_buffer(cell->draw, PIPE_SHADER_VERTEX, 0,

+ 160
- 94
src/gallium/drivers/cell/ppu/cell_texture.c Datei anzeigen

@@ -42,17 +42,17 @@
#include "cell_context.h"
#include "cell_screen.h"
#include "cell_state.h"
#include "cell_texture.h"
#include "cell_resource.h"

#include "state_tracker/sw_winsys.h"



static boolean
cell_texture_layout(struct pipe_screen *screen,
struct cell_texture *ct)
cell_resource_layout(struct pipe_screen *screen,
struct cell_resource *ct)
{
struct pipe_texture *pt = &ct->base;
struct pipe_resource *pt = &ct->base;
unsigned level;
unsigned width = pt->width0;
unsigned height = pt->height0;
@@ -98,7 +98,7 @@ cell_texture_layout(struct pipe_screen *screen,
*/
static boolean
cell_displaytarget_layout(struct pipe_screen *screen,
struct cell_texture * ct)
struct cell_resource * ct)
{
struct sw_winsys *winsys = cell_screen(screen)->winsys;

@@ -115,11 +115,11 @@ cell_displaytarget_layout(struct pipe_screen *screen,
return ct->dt != NULL;
}

static struct pipe_texture *
cell_texture_create(struct pipe_screen *screen,
const struct pipe_texture *templat)
static struct pipe_resource *
cell_resource_create(struct pipe_screen *screen,
const struct pipe_resource *templat)
{
struct cell_texture *ct = CALLOC_STRUCT(cell_texture);
struct cell_resource *ct = CALLOC_STRUCT(cell_resource);
if (!ct)
return NULL;

@@ -137,7 +137,7 @@ cell_texture_create(struct pipe_screen *screen,
goto fail;
}

if (!cell_texture_layout(screen, ct))
if (!cell_resource_layout(screen, ct))
goto fail;

return &ct->base;
@@ -155,18 +155,19 @@ fail:


static void
cell_texture_destroy(struct pipe_texture *pt)
cell_resource_destroy(struct pipe_resource *pt)
{
struct cell_screen *screen = cell_screen(pt->screen);
struct sw_winsys *winsys = screen->winsys;
struct cell_texture *ct = cell_texture(pt);
struct cell_resource *ct = cell_resource(pt);

if (ct->dt) {
/* display target */
winsys->displaytarget_destroy(winsys, ct->dt);
}

align_free(ct->data);
else if (!ct->userBuffer) {
align_free(ct->data);
}

FREE(ct);
}
@@ -304,17 +305,17 @@ untwiddle_image_uint(uint w, uint h, uint tile_size, uint *dst,

static struct pipe_surface *
cell_get_tex_surface(struct pipe_screen *screen,
struct pipe_texture *pt,
struct pipe_resource *pt,
unsigned face, unsigned level, unsigned zslice,
unsigned usage)
{
struct cell_texture *ct = cell_texture(pt);
struct cell_resource *ct = cell_resource(pt);
struct pipe_surface *ps;

ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
pipe_reference_init(&ps->reference, 1);
pipe_texture_reference(&ps->texture, pt);
pipe_resource_reference(&ps->texture, pt);
ps->format = pt->format;
ps->width = u_minify(pt->width0, level);
ps->height = u_minify(pt->height0, level);
@@ -345,7 +346,7 @@ cell_get_tex_surface(struct pipe_screen *screen,
static void
cell_tex_surface_destroy(struct pipe_surface *surf)
{
pipe_texture_reference(&surf->texture, NULL);
pipe_resource_reference(&surf->texture, NULL);
FREE(surf);
}

@@ -357,45 +358,47 @@ cell_tex_surface_destroy(struct pipe_surface *surf)
*/
static struct pipe_transfer *
cell_get_transfer(struct pipe_context *ctx,
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_resource *resource,
struct pipe_subresource sr,
enum pipe_transfer_usage usage,
const struct pipe_box *box)
{
struct cell_texture *ct = cell_texture(texture);
struct cell_resource *ct = cell_resource(resource);
struct cell_transfer *ctrans;
enum pipe_format *format = resource->format;

assert(resource);
assert(level <= resource->last_level);

assert(texture);
assert(level <= texture->last_level);
/* make sure the requested region is in the image bounds */
assert(box->x + box->width <= u_minify(resource->width0, sr.level));
assert(box->y + box->height <= u_minify(resource->height0, sr.level));
assert(box->z + box->depth <= u_minify(resource->depth0, sr.level));

ctrans = CALLOC_STRUCT(cell_transfer);
if (ctrans) {
struct pipe_transfer *pt = &ctrans->base;
pipe_texture_reference(&pt->texture, texture);
pt->x = x;
pt->y = y;
pt->width = w;
pt->height = h;
pt->stride = ct->stride[level];
pipe_resource_reference(&pt->resource, resource);
pt->sr = sr;
pt->usage = usage;
pt->face = face;
pt->level = level;
pt->zslice = zslice;
pt->box = *box;
pt->stride = ct->stride[sr.level];

ctrans->offset = ct->level_offset[level];
ctrans->offset = ct->level_offset[sr.level];

if (texture->target == PIPE_TEXTURE_CUBE) {
unsigned h_tile = align(u_minify(texture->height0, level), TILE_SIZE);
ctrans->offset += face * util_format_get_nblocksy(texture->format, h_tile) * pt->stride;
if (resource->target == PIPE_TEXTURE_CUBE) {
unsigned h_tile = align(u_minify(resource->height0, sr.level), TILE_SIZE);
ctrans->offset += sr.face * util_format_get_nblocksy(format, h_tile) * pt->stride;
}
else if (texture->target == PIPE_TEXTURE_3D) {
unsigned h_tile = align(u_minify(texture->height0, level), TILE_SIZE);
ctrans->offset += zslice * util_format_get_nblocksy(texture->format, h_tile) * pt->stride;
else if (resource->target == PIPE_TEXTURE_3D) {
unsigned h_tile = align(u_minify(resource->height0, sr.level), TILE_SIZE);
ctrans->offset += box->z * util_format_get_nblocksy(format, h_tile) * pt->stride;
}
else {
assert(face == 0);
assert(zslice == 0);
assert(sr.face == 0);
assert(box->z == 0);
}

return pt;
}
return NULL;
@@ -410,8 +413,8 @@ cell_transfer_destroy(struct pipe_context *ctx, struct pipe_transfer *t)
* needed post-processing to put them into hardware layout, this is
* where it would happen. For cell, nothing to do.
*/
assert (transfer->base.texture);
pipe_texture_reference(&transfer->base.texture, NULL);
assert (transfer->base.resource);
pipe_resource_reference(&transfer->base.resource, NULL);
FREE(transfer);
}

@@ -423,44 +426,63 @@ static void *
cell_transfer_map(struct pipe_context *ctx, struct pipe_transfer *transfer)
{
struct cell_transfer *ctrans = cell_transfer(transfer);
struct pipe_texture *pt = transfer->texture;
struct cell_texture *ct = cell_texture(pt);
const uint level = ctrans->base.level;
const uint texWidth = u_minify(pt->width0, level);
const uint texHeight = u_minify(pt->height0, level);
const uint stride = ct->stride[level];
unsigned size;
struct pipe_resource *pt = transfer->resource;
struct cell_resource *ct = cell_resource(pt);

assert(transfer->texture);
assert(transfer->resource);

if (ct->mapped == NULL) {
ct->mapped = ct->data;
}

/*
* Create a buffer of ordinary memory for the linear texture.
* This is the memory that the user will read/write.

/* Better test would be resource->is_linear
*/
size = util_format_get_stride(pt->format, align(texWidth, TILE_SIZE)) *
util_format_get_nblocksy(pt->format, align(texHeight, TILE_SIZE));

ctrans->map = align_malloc(size, 16);
if (!ctrans->map)
return NULL; /* out of memory */

if (transfer->usage & PIPE_TRANSFER_READ) {
/* need to untwiddle the texture to make a linear version */
const uint bpp = util_format_get_blocksize(ct->base.format);
if (bpp == 4) {
const uint *src = (uint *) (ct->mapped + ctrans->offset);
uint *dst = ctrans->map;
untwiddle_image_uint(texWidth, texHeight, TILE_SIZE,
dst, stride, src);
}
else {
// xxx fix
if (transfer->resource->target != PIPE_BUFFER) {
const uint level = ctrans->base.sr.level;
const uint texWidth = u_minify(pt->width0, level);
const uint texHeight = u_minify(pt->height0, level);
unsigned size;


/*
* Create a buffer of ordinary memory for the linear texture.
* This is the memory that the user will read/write.
*/
size = (util_format_get_stride(pt->format, align(texWidth, TILE_SIZE)) *
util_format_get_nblocksy(pt->format, align(texHeight, TILE_SIZE)));

ctrans->map = align_malloc(size, 16);
if (!ctrans->map)
return NULL; /* out of memory */

if (transfer->usage & PIPE_TRANSFER_READ) {
/* Textures always stored twiddled, need to untwiddle the
* texture to make a linear version.
*/
const uint bpp = util_format_get_blocksize(ct->base.format);
if (bpp == 4) {
const uint *src = (uint *) (ct->mapped + ctrans->offset);
uint *dst = ctrans->map;
untwiddle_image_uint(texWidth, texHeight, TILE_SIZE,
dst, transfer->stride, src);
}
else {
// xxx fix
}
}
}
else {
unsigned stride = transfer->stride;
enum pipe_format format = pt->format;
unsigned blocksize = util_format_get_blocksize(format);

ctrans->map = (ct->mapped +
ctrans->offset +
ctrans->base.box.y / util_format_get_blockheight(format) * stride +
ctrans->base.box.x / util_format_get_blockwidth(format) * blocksize);
}


return ctrans->map;
}
@@ -476,9 +498,9 @@ cell_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer *transfer)
{
struct cell_transfer *ctrans = cell_transfer(transfer);
struct pipe_texture *pt = transfer->texture;
struct cell_texture *ct = cell_texture(pt);
const uint level = ctrans->base.level;
struct pipe_resource *pt = transfer->resource;
struct cell_resource *ct = cell_resource(pt);
const uint level = ctrans->base.sr.level;
const uint texWidth = u_minify(pt->width0, level);
const uint texHeight = u_minify(pt->height0, level);
const uint stride = ct->stride[level];
@@ -488,22 +510,28 @@ cell_transfer_unmap(struct pipe_context *ctx,
return;
}

if (transfer->usage & PIPE_TRANSFER_WRITE) {
/* The user wrote new texture data into the mapped buffer.
* We need to convert the new linear data into the twiddled/tiled format.
*/
const uint bpp = util_format_get_blocksize(ct->base.format);
if (bpp == 4) {
const uint *src = ctrans->map;
uint *dst = (uint *) (ct->mapped + ctrans->offset);
twiddle_image_uint(texWidth, texHeight, TILE_SIZE, dst, stride, src);
}
else {
// xxx fix
if (pt->target != PIPE_BUFFER) {
if (transfer->usage & PIPE_TRANSFER_WRITE) {
/* The user wrote new texture data into the mapped buffer.
* We need to convert the new linear data into the twiddled/tiled format.
*/
const uint bpp = util_format_get_blocksize(ct->base.format);
if (bpp == 4) {
const uint *src = ctrans->map;
uint *dst = (uint *) (ct->mapped + ctrans->offset);
twiddle_image_uint(texWidth, texHeight, TILE_SIZE, dst, stride, src);
}
else {
// xxx fix
}
}
align_free(ctrans->map);
}
else {
/* nothing to do */
}

align_free(ctrans->map);
ctrans->map = NULL;
}

@@ -525,7 +553,7 @@ cell_flush_frontbuffer(struct pipe_screen *_screen,
{
struct cell_screen *screen = cell_screen(_screen);
struct sw_winsys *winsys = screen->winsys;
struct cell_texture *ct = cell_texture(surface->texture);
struct cell_resource *ct = cell_resource(surface->texture);

if (!ct->dt)
return;
@@ -552,11 +580,46 @@ cell_flush_frontbuffer(struct pipe_screen *_screen,
}



/**
* Create buffer which wraps user-space data.
*/
static struct pipe_resource *
cell_user_buffer_create(struct pipe_screen *screen,
void *ptr,
unsigned bytes,
unsigned usage)
{
struct cell_resource *buffer;

buffer = CALLOC_STRUCT(cell_resource);
if(!buffer)
return NULL;

pipe_reference_init(&buffer->base.reference, 1);
buffer->base.screen = screen;
buffer->base.format = PIPE_FORMAT_R8_UNORM; /* ?? */
buffer->base.usage = PIPE_BUFFER_USAGE_CPU_READ | usage;
buffer->base.width0 = bytes;
buffer->base.height0 = 1;
buffer->base.depth0 = 1;
buffer->userBuffer = TRUE;
buffer->data = ptr;

return &buffer->base;
}




void
cell_init_screen_texture_funcs(struct pipe_screen *screen)
{
screen->texture_create = cell_texture_create;
screen->texture_destroy = cell_texture_destroy;
screen->resource_create = cell_resource_create;
screen->resource_destroy = cell_resource_destroy;
screen->resource_from_handle = cell_resource_from_handle;
screen->resource_get_handle = cell_resource_get_handle;
screen->user_buffer_create = cell_user_buffer_create;

screen->get_tex_surface = cell_get_tex_surface;
screen->tex_surface_destroy = cell_tex_surface_destroy;
@@ -565,10 +628,13 @@ cell_init_screen_texture_funcs(struct pipe_screen *screen)
}

void
cell_init_texture_transfer_funcs(struct cell_context *cell)
cell_init_transfer_funcs(struct cell_context *cell)
{
cell->pipe.get_transfer = cell_get_transfer;
cell->pipe.transfer_destroy = cell_transfer_destroy;
cell->pipe.transfer_map = cell_transfer_map;
cell->pipe.transfer_unmap = cell_transfer_unmap;

cell->pipe.transfer_flush_region = u_default_transfer_flush_region;
cell->pipe.transfer_inline_write = u_default_transfer_inline_write;
}

+ 6
- 5
src/gallium/drivers/cell/ppu/cell_texture.h Datei anzeigen

@@ -37,9 +37,9 @@ struct pipe_texture;
/**
* Subclass of pipe_texture
*/
struct cell_texture
struct cell_resource
{
struct pipe_texture base;
struct pipe_resource base;

unsigned long level_offset[CELL_MAX_TEXTURE_LEVELS];
unsigned long stride[CELL_MAX_TEXTURE_LEVELS];
@@ -55,6 +55,7 @@ struct cell_texture
* Malloc'ed data for regular textures, or a mapping to dt above.
*/
void *data;
boolean userBuffer;

/* Size of the linear buffer??
*/
@@ -77,10 +78,10 @@ struct cell_transfer


/** cast wrapper */
static INLINE struct cell_texture *
cell_texture(struct pipe_texture *pt)
static INLINE struct cell_resource *
cell_resource(struct pipe_resource *pt)
{
return (struct cell_texture *) pt;
return (struct cell_resource *) pt;
}



+ 1
- 1
src/gallium/drivers/cell/spu/spu_exec.h Datei anzeigen

@@ -75,7 +75,7 @@ struct softpipe_tile_cache; /**< Opaque to TGSI */
struct spu_sampler
{
const struct pipe_sampler_state *state;
struct pipe_texture *texture;
struct pipe_resource *texture;
/** Get samples for four fragments in a quad */
void (*get_samples)(struct spu_sampler *sampler,
const float s[QUAD_SIZE],

+ 2
- 3
src/gallium/drivers/softpipe/sp_texture.c Datei anzeigen

@@ -331,11 +331,10 @@ softpipe_get_transfer(struct pipe_context *pipe,
int nblocksy = util_format_get_nblocksy(resource->format,
u_minify(resource->height0, sr.level));
pipe_resource_reference(&pt->resource, resource);
pt->sr = sr;
pt->usage = usage;
pt->box = *box;
pt->stride = sptex->stride[sr.level];
pt->usage = usage;
//pt->face = face;
//pt->level = level;

spt->offset = sptex->level_offset[sr.level];


Laden…
Abbrechen
Speichern