Add pipe buffer managment functions.
The state_tracker driver needs these to implement, eg. pixel buffer objects, vertex buffer objects.
This commit is contained in:
@@ -391,161 +391,4 @@ intelEmitCopyBlit(struct intel_context *intel,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use blitting to clear the renderbuffers named by 'flags'.
|
|
||||||
* Note: we can't use the ctx->DrawBuffer->_ColorDrawBufferMask field
|
|
||||||
* since that might include software renderbuffers or renderbuffers
|
|
||||||
* which we're clearing with triangles.
|
|
||||||
* \param mask bitmask of BUFFER_BIT_* values indicating buffers to clear
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
intelClearWithBlit(GLcontext * ctx, GLbitfield mask)
|
|
||||||
{
|
|
||||||
struct intel_context *intel = intel_context(ctx);
|
|
||||||
struct gl_framebuffer *fb = ctx->DrawBuffer;
|
|
||||||
GLuint clear_depth;
|
|
||||||
GLbitfield skipBuffers = 0;
|
|
||||||
BATCH_LOCALS;
|
|
||||||
|
|
||||||
DBG("%s %x\n", __FUNCTION__, mask);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Compute values for clearing the buffers.
|
|
||||||
*/
|
|
||||||
clear_depth = 0;
|
|
||||||
if (mask & BUFFER_BIT_DEPTH) {
|
|
||||||
clear_depth = (GLuint) (fb->_DepthMax * ctx->Depth.Clear);
|
|
||||||
}
|
|
||||||
if (mask & BUFFER_BIT_STENCIL) {
|
|
||||||
clear_depth |= (ctx->Stencil.Clear & 0xff) << 24;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If clearing both depth and stencil, skip BUFFER_BIT_STENCIL in
|
|
||||||
* the loop below.
|
|
||||||
*/
|
|
||||||
if ((mask & BUFFER_BIT_DEPTH) && (mask & BUFFER_BIT_STENCIL)) {
|
|
||||||
skipBuffers = BUFFER_BIT_STENCIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* XXX Move this flush/lock into the following conditional? */
|
|
||||||
intelFlush(&intel->ctx);
|
|
||||||
LOCK_HARDWARE(intel);
|
|
||||||
|
|
||||||
if (intel->numClipRects) {
|
|
||||||
GLint cx, cy, cw, ch;
|
|
||||||
drm_clip_rect_t b;
|
|
||||||
|
|
||||||
/* Get clear bounds after locking */
|
|
||||||
cx = fb->_Xmin;
|
|
||||||
cy = fb->_Ymin;
|
|
||||||
cw = fb->_Xmax - cx;
|
|
||||||
ch = fb->_Ymax - cy;
|
|
||||||
|
|
||||||
if (fb->Name == 0) {
|
|
||||||
/* clearing a window */
|
|
||||||
/* flip top to bottom */
|
|
||||||
b.x1 = cx;
|
|
||||||
b.y1 = fb->Height - cy - ch;
|
|
||||||
b.x2 = b.x1 + cw;
|
|
||||||
b.y2 = b.y1 + ch;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* clearing FBO */
|
|
||||||
b.x1 = cx;
|
|
||||||
b.y1 = cy;
|
|
||||||
b.x2 = b.x1 + cw;
|
|
||||||
b.y2 = b.y1 + ch;
|
|
||||||
/* no change to mask */
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
GLuint buf;
|
|
||||||
GLuint clearMask = mask; /* use copy, since we modify it below */
|
|
||||||
GLboolean all = (cw == fb->Width && ch == fb->Height);
|
|
||||||
|
|
||||||
DBG("clear %d,%d..%d,%d, mask %x\n",
|
|
||||||
b.x1, b.y1, b.x2, b.y2, mask);
|
|
||||||
|
|
||||||
/* Loop over all renderbuffers */
|
|
||||||
for (buf = 0; buf < BUFFER_COUNT && clearMask; buf++) {
|
|
||||||
const GLbitfield bufBit = 1 << buf;
|
|
||||||
if ((clearMask & bufBit) && !(bufBit & skipBuffers)) {
|
|
||||||
/* OK, clear this renderbuffer */
|
|
||||||
struct pipe_region *irb_region =
|
|
||||||
intel_get_rb_region(fb, buf);
|
|
||||||
struct _DriBufferObject *write_buffer =
|
|
||||||
intel->pipe->region_buffer(intel->pipe, irb_region,
|
|
||||||
all ? INTEL_WRITE_FULL :
|
|
||||||
INTEL_WRITE_PART);
|
|
||||||
|
|
||||||
GLuint clearVal;
|
|
||||||
GLint pitch, cpp;
|
|
||||||
GLuint BR13, CMD;
|
|
||||||
|
|
||||||
ASSERT(irb_region);
|
|
||||||
|
|
||||||
pitch = irb_region->pitch;
|
|
||||||
cpp = irb_region->cpp;
|
|
||||||
|
|
||||||
DBG("%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
|
|
||||||
__FUNCTION__,
|
|
||||||
irb_region->buffer, (pitch * cpp),
|
|
||||||
irb_region->draw_offset,
|
|
||||||
b.x1, b.y1, b.x2 - b.x1, b.y2 - b.y1);
|
|
||||||
|
|
||||||
|
|
||||||
/* Setup the blit command */
|
|
||||||
if (cpp == 4) {
|
|
||||||
BR13 = (0xF0 << 16) | (pitch * cpp) | (1 << 24) | (1 << 25);
|
|
||||||
if (buf == BUFFER_DEPTH || buf == BUFFER_STENCIL) {
|
|
||||||
CMD = XY_COLOR_BLT_CMD;
|
|
||||||
if (clearMask & BUFFER_BIT_DEPTH)
|
|
||||||
CMD |= XY_COLOR_BLT_WRITE_RGB;
|
|
||||||
if (clearMask & BUFFER_BIT_STENCIL)
|
|
||||||
CMD |= XY_COLOR_BLT_WRITE_ALPHA;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* clearing RGBA */
|
|
||||||
CMD = (XY_COLOR_BLT_CMD |
|
|
||||||
XY_COLOR_BLT_WRITE_ALPHA |
|
|
||||||
XY_COLOR_BLT_WRITE_RGB);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ASSERT(cpp == 2 || cpp == 0);
|
|
||||||
BR13 = (0xF0 << 16) | (pitch * cpp) | (1 << 24);
|
|
||||||
CMD = XY_COLOR_BLT_CMD;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buf == BUFFER_DEPTH || buf == BUFFER_STENCIL) {
|
|
||||||
clearVal = clear_depth;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
clearVal = (cpp == 4)
|
|
||||||
? intel->ClearColor8888 : intel->ClearColor565;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
_mesa_debug(ctx, "hardware blit clear buf %d rb id %d\n",
|
|
||||||
buf, irb->Base.Name);
|
|
||||||
*/
|
|
||||||
intel_wait_flips(intel, INTEL_BATCH_NO_CLIPRECTS);
|
|
||||||
|
|
||||||
BEGIN_BATCH(6, INTEL_BATCH_NO_CLIPRECTS);
|
|
||||||
OUT_BATCH(CMD);
|
|
||||||
OUT_BATCH(BR13);
|
|
||||||
OUT_BATCH((b.y1 << 16) | b.x1);
|
|
||||||
OUT_BATCH((b.y2 << 16) | b.x2);
|
|
||||||
OUT_RELOC(write_buffer, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE,
|
|
||||||
DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE,
|
|
||||||
irb_region->draw_offset);
|
|
||||||
OUT_BATCH(clearVal);
|
|
||||||
ADVANCE_BATCH();
|
|
||||||
clearMask &= ~bufBit; /* turn off bit, for faster loop exit */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
intel_batchbuffer_flush(intel->batch);
|
|
||||||
}
|
|
||||||
|
|
||||||
UNLOCK_HARDWARE(intel);
|
|
||||||
}
|
|
||||||
|
@@ -40,7 +40,6 @@
|
|||||||
#include "intel_depthstencil.h"
|
#include "intel_depthstencil.h"
|
||||||
#include "intel_fbo.h"
|
#include "intel_fbo.h"
|
||||||
#include "intel_mipmap_tree.h"
|
#include "intel_mipmap_tree.h"
|
||||||
#include "intel_regions.h"
|
|
||||||
#include "intel_tex.h"
|
#include "intel_tex.h"
|
||||||
|
|
||||||
#include "pipe/p_context.h"
|
#include "pipe/p_context.h"
|
||||||
|
@@ -54,15 +54,15 @@ struct intel_softpipe_winsys {
|
|||||||
* buffer pointer...
|
* buffer pointer...
|
||||||
*/
|
*/
|
||||||
static inline struct _DriBufferObject *
|
static inline struct _DriBufferObject *
|
||||||
dri_bo( struct softpipe_buffer_handle *bo )
|
dri_bo( struct pipe_buffer_handle *bo )
|
||||||
{
|
{
|
||||||
return (struct _DriBufferObject *)bo;
|
return (struct _DriBufferObject *)bo;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct softpipe_buffer_handle *
|
static inline struct pipe_buffer_handle *
|
||||||
pipe_bo( struct _DriBufferObject *bo )
|
pipe_bo( struct _DriBufferObject *bo )
|
||||||
{
|
{
|
||||||
return (struct softpipe_buffer_handle *)bo;
|
return (struct pipe_buffer_handle *)bo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Turn a softpipe winsys into an intel/softpipe winsys:
|
/* Turn a softpipe winsys into an intel/softpipe winsys:
|
||||||
@@ -77,36 +77,39 @@ intel_softpipe_winsys( struct softpipe_winsys *sws )
|
|||||||
/* Most callbacks map direcly onto dri_bufmgr operations:
|
/* Most callbacks map direcly onto dri_bufmgr operations:
|
||||||
*/
|
*/
|
||||||
static void *intel_buffer_map(struct softpipe_winsys *sws,
|
static void *intel_buffer_map(struct softpipe_winsys *sws,
|
||||||
struct softpipe_buffer_handle *buf )
|
struct pipe_buffer_handle *buf )
|
||||||
{
|
{
|
||||||
return driBOMap( dri_bo(buf),
|
return driBOMap( dri_bo(buf),
|
||||||
DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0 );
|
DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void intel_buffer_unmap(struct softpipe_winsys *sws,
|
static void intel_buffer_unmap(struct softpipe_winsys *sws,
|
||||||
struct softpipe_buffer_handle *buf)
|
struct pipe_buffer_handle *buf)
|
||||||
{
|
{
|
||||||
driBOUnmap( dri_bo(buf) );
|
driBOUnmap( dri_bo(buf) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct softpipe_buffer_handle *
|
static struct pipe_buffer_handle *
|
||||||
intel_buffer_reference(struct softpipe_winsys *sws,
|
intel_buffer_reference(struct softpipe_winsys *sws,
|
||||||
struct softpipe_buffer_handle *buf)
|
struct pipe_buffer_handle *buf)
|
||||||
{
|
{
|
||||||
return pipe_bo( driBOReference( dri_bo(buf) ) );
|
return pipe_bo( driBOReference( dri_bo(buf) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void intel_buffer_unreference(struct softpipe_winsys *sws,
|
static void intel_buffer_unreference(struct softpipe_winsys *sws,
|
||||||
struct softpipe_buffer_handle *buf)
|
struct pipe_buffer_handle **buf)
|
||||||
{
|
{
|
||||||
driBOUnReference( dri_bo(buf) );
|
if (*buf) {
|
||||||
|
driBOUnReference( dri_bo(*buf) );
|
||||||
|
*buf = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Grabs the hardware lock!
|
/* Grabs the hardware lock!
|
||||||
*/
|
*/
|
||||||
static void intel_buffer_data(struct softpipe_winsys *sws,
|
static void intel_buffer_data(struct softpipe_winsys *sws,
|
||||||
struct softpipe_buffer_handle *buf,
|
struct pipe_buffer_handle *buf,
|
||||||
unsigned size, const void *data )
|
unsigned size, const void *data )
|
||||||
{
|
{
|
||||||
struct intel_context *intel = intel_softpipe_winsys(sws)->intel;
|
struct intel_context *intel = intel_softpipe_winsys(sws)->intel;
|
||||||
@@ -117,7 +120,7 @@ static void intel_buffer_data(struct softpipe_winsys *sws,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void intel_buffer_subdata(struct softpipe_winsys *sws,
|
static void intel_buffer_subdata(struct softpipe_winsys *sws,
|
||||||
struct softpipe_buffer_handle *buf,
|
struct pipe_buffer_handle *buf,
|
||||||
unsigned long offset,
|
unsigned long offset,
|
||||||
unsigned long size,
|
unsigned long size,
|
||||||
const void *data)
|
const void *data)
|
||||||
@@ -126,7 +129,7 @@ static void intel_buffer_subdata(struct softpipe_winsys *sws,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void intel_buffer_get_subdata(struct softpipe_winsys *sws,
|
static void intel_buffer_get_subdata(struct softpipe_winsys *sws,
|
||||||
struct softpipe_buffer_handle *buf,
|
struct pipe_buffer_handle *buf,
|
||||||
unsigned long offset,
|
unsigned long offset,
|
||||||
unsigned long size,
|
unsigned long size,
|
||||||
void *data)
|
void *data)
|
||||||
@@ -137,9 +140,8 @@ static void intel_buffer_get_subdata(struct softpipe_winsys *sws,
|
|||||||
/* Softpipe has no concept of pools. We choose the tex/region pool
|
/* Softpipe has no concept of pools. We choose the tex/region pool
|
||||||
* for all buffers.
|
* for all buffers.
|
||||||
*/
|
*/
|
||||||
static struct softpipe_buffer_handle *
|
static struct pipe_buffer_handle *
|
||||||
intel_create_buffer(struct softpipe_winsys *sws,
|
intel_create_buffer(struct softpipe_winsys *sws,
|
||||||
const char *name,
|
|
||||||
unsigned alignment)
|
unsigned alignment)
|
||||||
{
|
{
|
||||||
struct intel_context *intel = intel_softpipe_winsys(sws)->intel;
|
struct intel_context *intel = intel_softpipe_winsys(sws)->intel;
|
||||||
@@ -147,7 +149,7 @@ intel_create_buffer(struct softpipe_winsys *sws,
|
|||||||
|
|
||||||
LOCK_HARDWARE( intel );
|
LOCK_HARDWARE( intel );
|
||||||
driGenBuffers( intel->intelScreen->regionPool,
|
driGenBuffers( intel->intelScreen->regionPool,
|
||||||
name, 1, &buffer, alignment, 0, 0 );
|
"softpipe buffer", 1, &buffer, alignment, 0, 0 );
|
||||||
UNLOCK_HARDWARE( intel );
|
UNLOCK_HARDWARE( intel );
|
||||||
|
|
||||||
return pipe_bo(buffer);
|
return pipe_bo(buffer);
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
#include "intel_context.h"
|
#include "intel_context.h"
|
||||||
#include "intel_buffers.h"
|
#include "intel_buffers.h"
|
||||||
#include "intel_regions.h"
|
|
||||||
#include "intel_fbo.h"
|
#include "intel_fbo.h"
|
||||||
|
|
||||||
#include "pipe/p_state.h"
|
#include "pipe/p_state.h"
|
||||||
|
@@ -225,9 +225,11 @@ try_pbo_upload(struct intel_context *intel,
|
|||||||
{
|
{
|
||||||
struct _DriBufferObject *src_buffer =
|
struct _DriBufferObject *src_buffer =
|
||||||
intel_bufferobj_buffer(intel, pbo, INTEL_READ);
|
intel_bufferobj_buffer(intel, pbo, INTEL_READ);
|
||||||
|
|
||||||
|
/* Temporary hack: cast to _DriBufferObject:
|
||||||
|
*/
|
||||||
struct _DriBufferObject *dst_buffer =
|
struct _DriBufferObject *dst_buffer =
|
||||||
intel->pipe->region_buffer(intel->pipe, intelImage->mt->region,
|
(struct _DriBufferObject *)intelImage->mt->region->buffer;
|
||||||
INTEL_WRITE_FULL);
|
|
||||||
|
|
||||||
|
|
||||||
intelEmitCopyBlit(intel,
|
intelEmitCopyBlit(intel,
|
||||||
|
@@ -39,6 +39,7 @@ $(LIBNAME): $(OBJECTS) Makefile $(TOP)/src/mesa/pipe/Makefile.template
|
|||||||
|
|
||||||
|
|
||||||
depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
|
depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
|
||||||
|
rm -f depend
|
||||||
touch depend
|
touch depend
|
||||||
$(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) \
|
$(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) \
|
||||||
$(ASM_SOURCES) 2> /dev/null
|
$(ASM_SOURCES) 2> /dev/null
|
||||||
|
@@ -169,9 +169,44 @@ struct pipe_context {
|
|||||||
GLuint width, GLuint height,
|
GLuint width, GLuint height,
|
||||||
GLuint value);
|
GLuint value);
|
||||||
|
|
||||||
struct _DriBufferObject *(*region_buffer)(struct pipe_context *pipe,
|
|
||||||
struct pipe_region *region,
|
/* Buffer management functions need to be exposed as well. A pipe
|
||||||
GLuint flag);
|
* buffer may be used as a texture, render target or vertex/index
|
||||||
|
* buffer, or some combination according to flags.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct pipe_buffer_handle *(*create_buffer)(struct pipe_context *pipe,
|
||||||
|
unsigned alignment,
|
||||||
|
unsigned flags );
|
||||||
|
|
||||||
|
void *(*buffer_map)( struct pipe_context *pipe,
|
||||||
|
struct pipe_buffer_handle *buf,
|
||||||
|
unsigned flags );
|
||||||
|
|
||||||
|
void (*buffer_unmap)( struct pipe_context *pipe,
|
||||||
|
struct pipe_buffer_handle *buf );
|
||||||
|
|
||||||
|
struct pipe_buffer_handle *(*buffer_reference)( struct pipe_context *pipe,
|
||||||
|
struct pipe_buffer_handle *buf );
|
||||||
|
|
||||||
|
void (*buffer_unreference)( struct pipe_context *pipe,
|
||||||
|
struct pipe_buffer_handle **buf );
|
||||||
|
|
||||||
|
void (*buffer_data)(struct pipe_context *pipe,
|
||||||
|
struct pipe_buffer_handle *buf,
|
||||||
|
unsigned size, const void *data );
|
||||||
|
|
||||||
|
void (*buffer_subdata)(struct pipe_context *pipe,
|
||||||
|
struct pipe_buffer_handle *buf,
|
||||||
|
unsigned long offset,
|
||||||
|
unsigned long size,
|
||||||
|
const void *data);
|
||||||
|
|
||||||
|
void (*buffer_get_subdata)(struct pipe_context *pipe,
|
||||||
|
struct pipe_buffer_handle *buf,
|
||||||
|
unsigned long offset,
|
||||||
|
unsigned long size,
|
||||||
|
void *data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -292,4 +292,17 @@ struct pipe_texture_object
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct pipe_buffer_handle;
|
||||||
|
|
||||||
|
#define PIPE_BUFFER_FLAG_READ 0x1
|
||||||
|
#define PIPE_BUFFER_FLAG_WRITE 0x2
|
||||||
|
|
||||||
|
#define PIPE_BUFFER_USE_TEXTURE 0x1
|
||||||
|
#define PIPE_BUFFER_USE_VERTEX_BUFFER 0x2
|
||||||
|
#define PIPE_BUFFER_USE_INDEX_BUFFER 0x4
|
||||||
|
#define PIPE_BUFFER_USE_RENDER_TARGET 0x8
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -5,6 +5,7 @@ include $(TOP)/configs/current
|
|||||||
LIBNAME = softpipe
|
LIBNAME = softpipe
|
||||||
|
|
||||||
DRIVER_SOURCES = \
|
DRIVER_SOURCES = \
|
||||||
|
sp_buffer.c \
|
||||||
sp_clear.c \
|
sp_clear.c \
|
||||||
sp_context.c \
|
sp_context.c \
|
||||||
sp_prim_setup.c \
|
sp_prim_setup.c \
|
||||||
|
119
src/mesa/pipe/softpipe/sp_buffer.c
Normal file
119
src/mesa/pipe/softpipe/sp_buffer.c
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
|
||||||
|
* 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 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
|
||||||
|
* THE COPYRIGHT HOLDERS, AUTHORS 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.
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice (including the
|
||||||
|
* next paragraph) shall be included in all copies or substantial portions
|
||||||
|
* of the Software.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
**************************************************************************/
|
||||||
|
/*
|
||||||
|
* Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "sp_context.h"
|
||||||
|
#include "sp_winsys.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Most callbacks map direcly onto winsys operations:
|
||||||
|
*/
|
||||||
|
static struct pipe_buffer_handle *
|
||||||
|
sp_create_buffer(struct pipe_context *pipe,
|
||||||
|
unsigned alignment,
|
||||||
|
unsigned flags)
|
||||||
|
{
|
||||||
|
struct softpipe_context *sp = softpipe_context( pipe );
|
||||||
|
return sp->winsys->create_buffer( sp->winsys, alignment );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *sp_buffer_map(struct pipe_context *pipe,
|
||||||
|
struct pipe_buffer_handle *buf,
|
||||||
|
unsigned flags )
|
||||||
|
{
|
||||||
|
struct softpipe_context *sp = softpipe_context( pipe );
|
||||||
|
return sp->winsys->buffer_map( sp->winsys, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sp_buffer_unmap(struct pipe_context *pipe,
|
||||||
|
struct pipe_buffer_handle *buf)
|
||||||
|
{
|
||||||
|
struct softpipe_context *sp = softpipe_context( pipe );
|
||||||
|
sp->winsys->buffer_unmap( sp->winsys, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct pipe_buffer_handle *
|
||||||
|
sp_buffer_reference(struct pipe_context *pipe,
|
||||||
|
struct pipe_buffer_handle *buf)
|
||||||
|
{
|
||||||
|
struct softpipe_context *sp = softpipe_context( pipe );
|
||||||
|
return sp->winsys->buffer_reference( sp->winsys, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sp_buffer_unreference(struct pipe_context *pipe,
|
||||||
|
struct pipe_buffer_handle **buf)
|
||||||
|
{
|
||||||
|
struct softpipe_context *sp = softpipe_context( pipe );
|
||||||
|
sp->winsys->buffer_unreference( sp->winsys, buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sp_buffer_data(struct pipe_context *pipe,
|
||||||
|
struct pipe_buffer_handle *buf,
|
||||||
|
unsigned size, const void *data )
|
||||||
|
{
|
||||||
|
struct softpipe_context *sp = softpipe_context( pipe );
|
||||||
|
sp->winsys->buffer_data( sp->winsys, buf, size, data );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sp_buffer_subdata(struct pipe_context *pipe,
|
||||||
|
struct pipe_buffer_handle *buf,
|
||||||
|
unsigned long offset,
|
||||||
|
unsigned long size,
|
||||||
|
const void *data)
|
||||||
|
{
|
||||||
|
struct softpipe_context *sp = softpipe_context( pipe );
|
||||||
|
sp->winsys->buffer_subdata( sp->winsys, buf, offset, size, data );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sp_buffer_get_subdata(struct pipe_context *pipe,
|
||||||
|
struct pipe_buffer_handle *buf,
|
||||||
|
unsigned long offset,
|
||||||
|
unsigned long size,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
struct softpipe_context *sp = softpipe_context( pipe );
|
||||||
|
sp->winsys->buffer_get_subdata( sp->winsys, buf, offset, size, data );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
sp_init_buffer_functions( struct softpipe_context *sp )
|
||||||
|
{
|
||||||
|
sp->pipe.create_buffer = sp_create_buffer;
|
||||||
|
sp->pipe.buffer_map = sp_buffer_map;
|
||||||
|
sp->pipe.buffer_unmap = sp_buffer_unmap;
|
||||||
|
sp->pipe.buffer_reference = sp_buffer_reference;
|
||||||
|
sp->pipe.buffer_unreference = sp_buffer_unreference;
|
||||||
|
sp->pipe.buffer_data = sp_buffer_data;
|
||||||
|
sp->pipe.buffer_subdata = sp_buffer_subdata;
|
||||||
|
sp->pipe.buffer_get_subdata = sp_buffer_get_subdata;
|
||||||
|
}
|
40
src/mesa/pipe/softpipe/sp_buffer.h
Normal file
40
src/mesa/pipe/softpipe/sp_buffer.h
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||||
|
* 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 TUNGSTEN GRAPHICS 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
|
||||||
|
|
||||||
|
|
||||||
|
struct softpipe_context;
|
||||||
|
|
||||||
|
|
||||||
|
extern void
|
||||||
|
sp_init_buffer_functions(struct softpipe_context *sp);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* SP_BUFFER_H */
|
@@ -36,6 +36,7 @@
|
|||||||
#include "sp_context.h"
|
#include "sp_context.h"
|
||||||
#include "sp_clear.h"
|
#include "sp_clear.h"
|
||||||
#include "sp_region.h"
|
#include "sp_region.h"
|
||||||
|
#include "sp_buffer.h"
|
||||||
#include "sp_state.h"
|
#include "sp_state.h"
|
||||||
#include "sp_surface.h"
|
#include "sp_surface.h"
|
||||||
#include "sp_prim_setup.h"
|
#include "sp_prim_setup.h"
|
||||||
@@ -219,6 +220,7 @@ struct pipe_context *softpipe_create( struct softpipe_winsys *sws )
|
|||||||
assert(softpipe->draw);
|
assert(softpipe->draw);
|
||||||
draw_set_setup_stage(softpipe->draw, sp_draw_render_stage(softpipe));
|
draw_set_setup_stage(softpipe->draw, sp_draw_render_stage(softpipe));
|
||||||
|
|
||||||
|
sp_init_buffer_functions(softpipe);
|
||||||
sp_init_region_functions(softpipe);
|
sp_init_region_functions(softpipe);
|
||||||
sp_init_surface_functions(softpipe);
|
sp_init_surface_functions(softpipe);
|
||||||
|
|
||||||
|
@@ -80,7 +80,7 @@ sp_region_alloc(struct pipe_context *pipe,
|
|||||||
region->height = height; /* needed? */
|
region->height = height; /* needed? */
|
||||||
region->refcount = 1;
|
region->refcount = 1;
|
||||||
|
|
||||||
region->buffer = sp->winsys->create_buffer(sp->winsys, "region", 64 );
|
region->buffer = sp->winsys->create_buffer( sp->winsys, 64 );
|
||||||
|
|
||||||
sp->winsys->buffer_data( sp->winsys,
|
sp->winsys->buffer_data( sp->winsys,
|
||||||
region->buffer,
|
region->buffer,
|
||||||
@@ -259,13 +259,6 @@ sp_region_fill(struct pipe_context *pipe,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static struct _DriBufferObject *
|
|
||||||
sp_region_buffer(struct pipe_context *pipe,
|
|
||||||
struct pipe_region *region, GLuint flag)
|
|
||||||
{
|
|
||||||
return region->buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -279,6 +272,5 @@ sp_init_region_functions(struct softpipe_context *sp)
|
|||||||
sp->pipe.region_data = sp_region_data;
|
sp->pipe.region_data = sp_region_data;
|
||||||
sp->pipe.region_copy = sp_region_copy;
|
sp->pipe.region_copy = sp_region_copy;
|
||||||
sp->pipe.region_fill = sp_region_fill;
|
sp->pipe.region_fill = sp_region_fill;
|
||||||
sp->pipe.region_buffer = sp_region_buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,7 +46,7 @@
|
|||||||
* etc.
|
* etc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct softpipe_buffer_handle;
|
struct pipe_buffer_handle;
|
||||||
|
|
||||||
struct softpipe_winsys {
|
struct softpipe_winsys {
|
||||||
|
|
||||||
@@ -60,34 +60,33 @@ struct softpipe_winsys {
|
|||||||
* Softpipe only really wants to make system memory allocations,
|
* Softpipe only really wants to make system memory allocations,
|
||||||
* right??
|
* right??
|
||||||
*/
|
*/
|
||||||
struct softpipe_buffer_handle *(*create_buffer)(struct softpipe_winsys *sws,
|
struct pipe_buffer_handle *(*create_buffer)(struct softpipe_winsys *sws,
|
||||||
const char *name,
|
|
||||||
unsigned alignment );
|
unsigned alignment );
|
||||||
|
|
||||||
void *(*buffer_map)( struct softpipe_winsys *sws,
|
void *(*buffer_map)( struct softpipe_winsys *sws,
|
||||||
struct softpipe_buffer_handle *buf );
|
struct pipe_buffer_handle *buf );
|
||||||
|
|
||||||
void (*buffer_unmap)( struct softpipe_winsys *sws,
|
void (*buffer_unmap)( struct softpipe_winsys *sws,
|
||||||
struct softpipe_buffer_handle *buf );
|
struct pipe_buffer_handle *buf );
|
||||||
|
|
||||||
struct softpipe_buffer_handle *(*buffer_reference)( struct softpipe_winsys *sws,
|
struct pipe_buffer_handle *(*buffer_reference)( struct softpipe_winsys *sws,
|
||||||
struct softpipe_buffer_handle *buf );
|
struct pipe_buffer_handle *buf );
|
||||||
|
|
||||||
void (*buffer_unreference)( struct softpipe_winsys *sws,
|
void (*buffer_unreference)( struct softpipe_winsys *sws,
|
||||||
struct softpipe_buffer_handle *buf );
|
struct pipe_buffer_handle **buf );
|
||||||
|
|
||||||
void (*buffer_data)(struct softpipe_winsys *sws,
|
void (*buffer_data)(struct softpipe_winsys *sws,
|
||||||
struct softpipe_buffer_handle *buf,
|
struct pipe_buffer_handle *buf,
|
||||||
unsigned size, const void *data );
|
unsigned size, const void *data );
|
||||||
|
|
||||||
void (*buffer_subdata)(struct softpipe_winsys *sws,
|
void (*buffer_subdata)(struct softpipe_winsys *sws,
|
||||||
struct softpipe_buffer_handle *buf,
|
struct pipe_buffer_handle *buf,
|
||||||
unsigned long offset,
|
unsigned long offset,
|
||||||
unsigned long size,
|
unsigned long size,
|
||||||
const void *data);
|
const void *data);
|
||||||
|
|
||||||
void (*buffer_get_subdata)(struct softpipe_winsys *sws,
|
void (*buffer_get_subdata)(struct softpipe_winsys *sws,
|
||||||
struct softpipe_buffer_handle *buf,
|
struct pipe_buffer_handle *buf,
|
||||||
unsigned long offset,
|
unsigned long offset,
|
||||||
unsigned long size,
|
unsigned long size,
|
||||||
void *data);
|
void *data);
|
||||||
|
@@ -196,6 +196,7 @@ STATETRACKER_SOURCES = \
|
|||||||
state_tracker/st_cb_fbo.c \
|
state_tracker/st_cb_fbo.c \
|
||||||
state_tracker/st_cb_program.c \
|
state_tracker/st_cb_program.c \
|
||||||
state_tracker/st_cb_teximage.c \
|
state_tracker/st_cb_teximage.c \
|
||||||
|
state_tracker/st_cb_bufferobjects.c \
|
||||||
state_tracker/st_draw.c \
|
state_tracker/st_draw.c \
|
||||||
state_tracker/st_context.c \
|
state_tracker/st_context.c \
|
||||||
state_tracker/st_texobj.c
|
state_tracker/st_texobj.c
|
||||||
|
206
src/mesa/state_tracker/st_cb_bufferobjects.c
Normal file
206
src/mesa/state_tracker/st_cb_bufferobjects.c
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||||
|
* 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 TUNGSTEN GRAPHICS 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 "imports.h"
|
||||||
|
#include "mtypes.h"
|
||||||
|
#include "bufferobj.h"
|
||||||
|
|
||||||
|
#include "st_context.h"
|
||||||
|
#include "st_cb_bufferobjects.h"
|
||||||
|
|
||||||
|
#include "pipe/p_context.h"
|
||||||
|
|
||||||
|
/* Pixel buffers and Vertex/index buffers are handled through these
|
||||||
|
* mesa callbacks. Framebuffer/Renderbuffer objects are
|
||||||
|
* created/managed elsewhere.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* There is some duplication between mesa's bufferobjects and our
|
||||||
|
* bufmgr buffers. Both have an integer handle and a hashtable to
|
||||||
|
* lookup an opaque structure. It would be nice if the handles and
|
||||||
|
* internal structure where somehow shared.
|
||||||
|
*/
|
||||||
|
static struct gl_buffer_object *
|
||||||
|
st_bufferobj_alloc(GLcontext *ctx, GLuint name, GLenum target)
|
||||||
|
{
|
||||||
|
struct st_context *st = st_context(ctx);
|
||||||
|
struct st_buffer_object *st_obj = CALLOC_STRUCT(st_buffer_object);
|
||||||
|
|
||||||
|
_mesa_initialize_buffer_object(&st_obj->Base, name, target);
|
||||||
|
|
||||||
|
st_obj->buffer = st->pipe->create_buffer( st->pipe, 32, 0 );
|
||||||
|
|
||||||
|
return &st_obj->Base;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deallocate/free a vertex/pixel buffer object.
|
||||||
|
* Called via glDeleteBuffersARB().
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj)
|
||||||
|
{
|
||||||
|
struct pipe_context *pipe = st_context(ctx)->pipe;
|
||||||
|
struct st_buffer_object *st_obj = st_buffer_object(obj);
|
||||||
|
|
||||||
|
if (st_obj->buffer)
|
||||||
|
pipe->buffer_unreference(pipe, &st_obj->buffer);
|
||||||
|
|
||||||
|
FREE(st_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allocate space for and store data in a buffer object. Any data that was
|
||||||
|
* previously stored in the buffer object is lost. If data is NULL,
|
||||||
|
* memory will be allocated, but no copy will occur.
|
||||||
|
* Called via glBufferDataARB().
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
st_bufferobj_data(GLcontext *ctx,
|
||||||
|
GLenum target,
|
||||||
|
GLsizeiptrARB size,
|
||||||
|
const GLvoid * data,
|
||||||
|
GLenum usage,
|
||||||
|
struct gl_buffer_object *obj)
|
||||||
|
{
|
||||||
|
struct pipe_context *pipe = st_context(ctx)->pipe;
|
||||||
|
struct st_buffer_object *st_obj = st_buffer_object(obj);
|
||||||
|
|
||||||
|
st_obj->Base.Size = size;
|
||||||
|
st_obj->Base.Usage = usage;
|
||||||
|
|
||||||
|
pipe->buffer_data( pipe, st_obj->buffer, size, data );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace data in a subrange of buffer object. If the data range
|
||||||
|
* specified by size + offset extends beyond the end of the buffer or
|
||||||
|
* if data is NULL, no copy is performed.
|
||||||
|
* Called via glBufferSubDataARB().
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
st_bufferobj_subdata(GLcontext *ctx,
|
||||||
|
GLenum target,
|
||||||
|
GLintptrARB offset,
|
||||||
|
GLsizeiptrARB size,
|
||||||
|
const GLvoid * data, struct gl_buffer_object *obj)
|
||||||
|
{
|
||||||
|
struct pipe_context *pipe = st_context(ctx)->pipe;
|
||||||
|
struct st_buffer_object *st_obj = st_buffer_object(obj);
|
||||||
|
|
||||||
|
pipe->buffer_subdata(pipe, st_obj->buffer, offset, size, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called via glGetBufferSubDataARB().
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
st_bufferobj_get_subdata(GLcontext *ctx,
|
||||||
|
GLenum target,
|
||||||
|
GLintptrARB offset,
|
||||||
|
GLsizeiptrARB size,
|
||||||
|
GLvoid * data, struct gl_buffer_object *obj)
|
||||||
|
{
|
||||||
|
struct pipe_context *pipe = st_context(ctx)->pipe;
|
||||||
|
struct st_buffer_object *st_obj = st_buffer_object(obj);
|
||||||
|
|
||||||
|
pipe->buffer_get_subdata(pipe, st_obj->buffer, offset, size, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called via glMapBufferARB().
|
||||||
|
*/
|
||||||
|
static void *
|
||||||
|
st_bufferobj_map(GLcontext *ctx,
|
||||||
|
GLenum target,
|
||||||
|
GLenum access, struct gl_buffer_object *obj)
|
||||||
|
{
|
||||||
|
struct pipe_context *pipe = st_context(ctx)->pipe;
|
||||||
|
struct st_buffer_object *st_obj = st_buffer_object(obj);
|
||||||
|
GLuint flags;
|
||||||
|
|
||||||
|
switch (access) {
|
||||||
|
case GL_WRITE_ONLY:
|
||||||
|
flags = PIPE_BUFFER_FLAG_WRITE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
flags = PIPE_BUFFER_FLAG_READ;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GL_READ_WRITE:
|
||||||
|
default:
|
||||||
|
flags = PIPE_BUFFER_FLAG_READ | PIPE_BUFFER_FLAG_WRITE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
obj->Pointer = pipe->buffer_map(pipe, st_obj->buffer, flags);
|
||||||
|
return obj->Pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called via glMapBufferARB().
|
||||||
|
*/
|
||||||
|
static GLboolean
|
||||||
|
st_bufferobj_unmap(GLcontext *ctx,
|
||||||
|
GLenum target, struct gl_buffer_object *obj)
|
||||||
|
{
|
||||||
|
struct pipe_context *pipe = st_context(ctx)->pipe;
|
||||||
|
struct st_buffer_object *st_obj = st_buffer_object(obj);
|
||||||
|
|
||||||
|
pipe->buffer_unmap(pipe, st_obj->buffer);
|
||||||
|
obj->Pointer = NULL;
|
||||||
|
return GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
st_init_cb_bufferobjects( struct st_context *st )
|
||||||
|
{
|
||||||
|
GLcontext *ctx = st->ctx;
|
||||||
|
|
||||||
|
ctx->Driver.NewBufferObject = st_bufferobj_alloc;
|
||||||
|
ctx->Driver.DeleteBuffer = st_bufferobj_free;
|
||||||
|
ctx->Driver.BufferData = st_bufferobj_data;
|
||||||
|
ctx->Driver.BufferSubData = st_bufferobj_subdata;
|
||||||
|
ctx->Driver.GetBufferSubData = st_bufferobj_get_subdata;
|
||||||
|
ctx->Driver.MapBuffer = st_bufferobj_map;
|
||||||
|
ctx->Driver.UnmapBuffer = st_bufferobj_unmap;
|
||||||
|
}
|
66
src/mesa/state_tracker/st_cb_bufferobjects.h
Normal file
66
src/mesa/state_tracker/st_cb_bufferobjects.h
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright 2005 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||||
|
* 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 TUNGSTEN GRAPHICS 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 ST_CB_BUFFEROBJECTS_H
|
||||||
|
#define ST_CB_BUFFEROBJECTS_H
|
||||||
|
|
||||||
|
struct st_context;
|
||||||
|
struct gl_buffer_object;
|
||||||
|
struct pipe_buffer_handle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* State_tracker vertex/pixel buffer object, derived from Mesa's
|
||||||
|
* gl_buffer_object.
|
||||||
|
*/
|
||||||
|
struct st_buffer_object
|
||||||
|
{
|
||||||
|
struct gl_buffer_object Base;
|
||||||
|
struct pipe_buffer_handle *buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Hook the bufferobject implementation into mesa:
|
||||||
|
*/
|
||||||
|
void st_init_cb_bufferobjects( struct st_context *st );
|
||||||
|
|
||||||
|
|
||||||
|
/* Are the obj->Name tests necessary? Unfortunately yes, mesa
|
||||||
|
* allocates a couple of gl_buffer_object structs statically, and the
|
||||||
|
* Name == 0 test is the only way to identify them and avoid casting
|
||||||
|
* them erroneously to our structs.
|
||||||
|
*/
|
||||||
|
static INLINE struct st_buffer_object *
|
||||||
|
st_buffer_object(struct gl_buffer_object *obj)
|
||||||
|
{
|
||||||
|
if (obj->Name)
|
||||||
|
return (struct st_buffer_object *) obj;
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user