Commit f29ac73f authored by Keith Whitwell's avatar Keith Whitwell

cell: attempt to convert to pipe_resources

Can't even compile test this driver.
parent 484b1947
......@@ -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 \
......
/**************************************************************************
*
* 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;
}
/**************************************************************************
*
* 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 */
......@@ -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;
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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",
......
......@@ -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;
}
......
......@@ -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;
}
......@@ -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 +
......
......@@ -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,
......
This diff is collapsed.
......@@ -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;
}
......
......@@ -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],
......
......@@ -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];
......
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