mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 02:38:04 +02:00
Use tile functions in new p_tile.[ch]
This removes quite a bit of code duplicated in the drivers.
This commit is contained in:
parent
bccc4c5c01
commit
263e8f0572
5 changed files with 23 additions and 261 deletions
|
|
@ -33,89 +33,7 @@
|
|||
#include "pipe/p_util.h"
|
||||
#include "pipe/p_inlines.h"
|
||||
#include "pipe/p_winsys.h"
|
||||
|
||||
#include "pipe/softpipe/sp_rgba_tile.h" /* XXX TEMPORARY */
|
||||
|
||||
|
||||
#define CLIP_TILE \
|
||||
do { \
|
||||
if (x >= ps->width) \
|
||||
return; \
|
||||
if (y >= ps->height) \
|
||||
return; \
|
||||
if (x + w > ps->width) \
|
||||
w = ps->width - x; \
|
||||
if (y + h > ps->height) \
|
||||
h = ps->height -y; \
|
||||
} while(0)
|
||||
|
||||
|
||||
/*
|
||||
* XXX note: same as code in sp_surface.c
|
||||
*/
|
||||
static void
|
||||
i915_get_tile(struct pipe_context *pipe,
|
||||
struct pipe_surface *ps,
|
||||
uint x, uint y, uint w, uint h,
|
||||
void *p, int dst_stride)
|
||||
{
|
||||
const uint cpp = ps->cpp;
|
||||
const uint w0 = w;
|
||||
const ubyte *pSrc;
|
||||
ubyte *pDest;
|
||||
uint i;
|
||||
|
||||
assert(ps->map);
|
||||
|
||||
CLIP_TILE;
|
||||
|
||||
if (dst_stride == 0) {
|
||||
dst_stride = w0 * cpp;
|
||||
}
|
||||
|
||||
pSrc = ps->map + (y * ps->pitch + x) * cpp;
|
||||
pDest = (ubyte *) p;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
memcpy(pDest, pSrc, w0 * cpp);
|
||||
pDest += dst_stride;
|
||||
pSrc += ps->pitch * cpp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* XXX note: same as code in sp_surface.c
|
||||
*/
|
||||
static void
|
||||
i915_put_tile(struct pipe_context *pipe,
|
||||
struct pipe_surface *ps,
|
||||
uint x, uint y, uint w, uint h,
|
||||
const void *p, int src_stride)
|
||||
{
|
||||
const uint cpp = ps->cpp;
|
||||
const uint w0 = w;
|
||||
const ubyte *pSrc;
|
||||
ubyte *pDest;
|
||||
uint i;
|
||||
|
||||
assert(ps->map);
|
||||
|
||||
CLIP_TILE;
|
||||
|
||||
if (src_stride == 0) {
|
||||
src_stride = w0 * cpp;
|
||||
}
|
||||
|
||||
pSrc = (const ubyte *) p;
|
||||
pDest = ps->map + (y * ps->pitch + x) * cpp;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
memcpy(pDest, pSrc, w0 * cpp);
|
||||
pDest += ps->pitch * cpp;
|
||||
pSrc += src_stride;
|
||||
}
|
||||
}
|
||||
#include "pipe/util/p_tile.h"
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -323,10 +241,10 @@ void
|
|||
i915_init_surface_functions(struct i915_context *i915)
|
||||
{
|
||||
i915->pipe.get_tex_surface = i915_get_tex_surface;
|
||||
i915->pipe.get_tile = i915_get_tile;
|
||||
i915->pipe.put_tile = i915_put_tile;
|
||||
i915->pipe.get_tile_rgba = softpipe_get_tile_rgba;
|
||||
i915->pipe.put_tile_rgba = softpipe_put_tile_rgba;
|
||||
i915->pipe.get_tile = pipe_get_tile_raw;
|
||||
i915->pipe.put_tile = pipe_put_tile_raw;
|
||||
i915->pipe.get_tile_rgba = pipe_get_tile_rgba;
|
||||
i915->pipe.put_tile_rgba = pipe_put_tile_rgba;
|
||||
|
||||
i915->pipe.surface_data = i915_surface_data;
|
||||
i915->pipe.surface_copy = i915_surface_copy;
|
||||
|
|
|
|||
|
|
@ -32,89 +32,7 @@
|
|||
#include "pipe/p_util.h"
|
||||
#include "pipe/p_inlines.h"
|
||||
#include "pipe/p_winsys.h"
|
||||
|
||||
#include "pipe/softpipe/sp_rgba_tile.h" /* XXX TEMPORARY */
|
||||
|
||||
|
||||
#define CLIP_TILE \
|
||||
do { \
|
||||
if (x >= ps->width) \
|
||||
return; \
|
||||
if (y >= ps->height) \
|
||||
return; \
|
||||
if (x + w > ps->width) \
|
||||
w = ps->width - x; \
|
||||
if (y + h > ps->height) \
|
||||
h = ps->height -y; \
|
||||
} while(0)
|
||||
|
||||
|
||||
/*
|
||||
* XXX note: same as code in sp_surface.c
|
||||
*/
|
||||
static void
|
||||
brw_get_tile(struct pipe_context *pipe,
|
||||
struct pipe_surface *ps,
|
||||
uint x, uint y, uint w, uint h,
|
||||
void *p, int dst_stride)
|
||||
{
|
||||
const uint cpp = ps->cpp;
|
||||
const uint w0 = w;
|
||||
const ubyte *pSrc;
|
||||
ubyte *pDest;
|
||||
uint i;
|
||||
|
||||
assert(ps->map);
|
||||
|
||||
CLIP_TILE;
|
||||
|
||||
if (dst_stride == 0) {
|
||||
dst_stride = w0 * cpp;
|
||||
}
|
||||
|
||||
pSrc = ps->map + ps->offset + (y * ps->pitch + x) * cpp;
|
||||
pDest = (ubyte *) p;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
memcpy(pDest, pSrc, w0 * cpp);
|
||||
pDest += dst_stride;
|
||||
pSrc += ps->pitch * cpp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* XXX note: same as code in sp_surface.c
|
||||
*/
|
||||
static void
|
||||
brw_put_tile(struct pipe_context *pipe,
|
||||
struct pipe_surface *ps,
|
||||
uint x, uint y, uint w, uint h,
|
||||
const void *p, int src_stride)
|
||||
{
|
||||
const uint cpp = ps->cpp;
|
||||
const uint w0 = w;
|
||||
const ubyte *pSrc;
|
||||
ubyte *pDest;
|
||||
uint i;
|
||||
|
||||
assert(ps->map);
|
||||
|
||||
CLIP_TILE;
|
||||
|
||||
if (src_stride == 0) {
|
||||
src_stride = w0 * cpp;
|
||||
}
|
||||
|
||||
pSrc = (const ubyte *) p;
|
||||
pDest = ps->map + ps->offset + (y * ps->pitch + x) * cpp;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
memcpy(pDest, pSrc, w0 * cpp);
|
||||
pDest += ps->pitch * cpp;
|
||||
pSrc += src_stride;
|
||||
}
|
||||
}
|
||||
#include "pipe/util/p_tile.h"
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -321,10 +239,10 @@ void
|
|||
brw_init_surface_functions(struct brw_context *brw)
|
||||
{
|
||||
brw->pipe.get_tex_surface = brw_get_tex_surface;
|
||||
brw->pipe.get_tile = brw_get_tile;
|
||||
brw->pipe.put_tile = brw_put_tile;
|
||||
brw->pipe.get_tile_rgba = softpipe_get_tile_rgba;
|
||||
brw->pipe.put_tile_rgba = softpipe_put_tile_rgba;
|
||||
brw->pipe.get_tile = pipe_get_tile_raw;
|
||||
brw->pipe.put_tile = pipe_put_tile_raw;
|
||||
brw->pipe.get_tile_rgba = pipe_get_tile_rgba;
|
||||
brw->pipe.put_tile_rgba = pipe_put_tile_rgba;
|
||||
|
||||
brw->pipe.surface_data = brw_surface_data;
|
||||
brw->pipe.surface_copy = brw_surface_copy;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ DRIVER_SOURCES = \
|
|||
sp_quad_output.c \
|
||||
sp_quad_stencil.c \
|
||||
sp_quad_stipple.c \
|
||||
sp_rgba_tile.c \
|
||||
sp_state_blend.c \
|
||||
sp_state_clip.c \
|
||||
sp_state_derived.c \
|
||||
|
|
|
|||
|
|
@ -29,24 +29,10 @@
|
|||
#include "pipe/p_util.h"
|
||||
#include "pipe/p_inlines.h"
|
||||
#include "pipe/p_winsys.h"
|
||||
#include "pipe/util/p_tile.h"
|
||||
#include "sp_context.h"
|
||||
#include "sp_surface.h"
|
||||
#include "sp_texture.h"
|
||||
#include "sp_rgba_tile.h"
|
||||
|
||||
|
||||
|
||||
#define CLIP_TILE \
|
||||
do { \
|
||||
if (x >= ps->width) \
|
||||
return; \
|
||||
if (y >= ps->height) \
|
||||
return; \
|
||||
if (x + w > ps->width) \
|
||||
w = ps->width - x; \
|
||||
if (y + h > ps->height) \
|
||||
h = ps->height - y; \
|
||||
} while(0)
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -90,72 +76,6 @@ softpipe_get_tex_surface(struct pipe_context *pipe,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Move raw block of pixels from surface to user memory.
|
||||
*/
|
||||
void
|
||||
softpipe_get_tile(struct pipe_context *pipe, struct pipe_surface *ps,
|
||||
uint x, uint y, uint w, uint h,
|
||||
void *p, int dst_stride)
|
||||
{
|
||||
const uint cpp = ps->cpp;
|
||||
const ubyte *pSrc;
|
||||
const uint src_stride = ps->pitch * cpp;
|
||||
ubyte *pDest;
|
||||
uint i;
|
||||
|
||||
assert(ps->map);
|
||||
|
||||
if (dst_stride == 0) {
|
||||
dst_stride = w * cpp;
|
||||
}
|
||||
|
||||
CLIP_TILE;
|
||||
|
||||
pSrc = ps->map + (y * ps->pitch + x) * cpp;
|
||||
pDest = (ubyte *) p;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
memcpy(pDest, pSrc, w * cpp);
|
||||
pDest += dst_stride;
|
||||
pSrc += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Move raw block of pixels from user memory to surface.
|
||||
*/
|
||||
void
|
||||
softpipe_put_tile(struct pipe_context *pipe, struct pipe_surface *ps,
|
||||
uint x, uint y, uint w, uint h,
|
||||
const void *p, int src_stride)
|
||||
{
|
||||
const uint cpp = ps->cpp;
|
||||
const ubyte *pSrc;
|
||||
const uint dst_stride = ps->pitch * cpp;
|
||||
ubyte *pDest;
|
||||
uint i;
|
||||
|
||||
assert(ps->map);
|
||||
|
||||
if (src_stride == 0) {
|
||||
src_stride = w * cpp;
|
||||
}
|
||||
|
||||
CLIP_TILE;
|
||||
|
||||
pSrc = (const ubyte *) p;
|
||||
pDest = ps->map + (y * ps->pitch + x) * cpp;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
memcpy(pDest, pSrc, w * cpp);
|
||||
pDest += dst_stride;
|
||||
pSrc += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy 2D rect from one place to another.
|
||||
* Position and sizes are in pixels.
|
||||
|
|
@ -308,6 +228,10 @@ sp_surface_fill(struct pipe_context *pipe,
|
|||
ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff);
|
||||
ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff);
|
||||
ushort val3 = UBYTE_TO_USHORT((value >> 24) & 0xff);
|
||||
val0 = (val0 << 8) | val0;
|
||||
val1 = (val1 << 8) | val1;
|
||||
val2 = (val2 << 8) | val2;
|
||||
val3 = (val3 << 8) | val3;
|
||||
for (i = 0; i < height; i++) {
|
||||
for (j = 0; j < width; j++) {
|
||||
row[j*4+0] = val0;
|
||||
|
|
@ -331,11 +255,10 @@ sp_surface_fill(struct pipe_context *pipe,
|
|||
void
|
||||
sp_init_surface_functions(struct softpipe_context *sp)
|
||||
{
|
||||
sp->pipe.get_tile = softpipe_get_tile;
|
||||
sp->pipe.put_tile = softpipe_put_tile;
|
||||
|
||||
sp->pipe.get_tile_rgba = softpipe_get_tile_rgba;
|
||||
sp->pipe.put_tile_rgba = softpipe_put_tile_rgba;
|
||||
sp->pipe.get_tile = pipe_get_tile_raw;
|
||||
sp->pipe.put_tile = pipe_put_tile_raw;
|
||||
sp->pipe.get_tile_rgba = pipe_get_tile_rgba;
|
||||
sp->pipe.put_tile_rgba = pipe_put_tile_rgba;
|
||||
|
||||
sp->pipe.surface_data = sp_surface_data;
|
||||
sp->pipe.surface_copy = sp_surface_copy;
|
||||
|
|
|
|||
|
|
@ -196,6 +196,9 @@ STATECACHE_SOURCES = \
|
|||
pipe/cso_cache/cso_hash.c \
|
||||
pipe/cso_cache/cso_cache.c
|
||||
|
||||
PIPEUTIL_SOURCES = \
|
||||
pipe/util/p_tile.c
|
||||
|
||||
STATETRACKER_SOURCES = \
|
||||
state_tracker/st_atom.c \
|
||||
state_tracker/st_atom_alphatest.c \
|
||||
|
|
@ -383,6 +386,7 @@ SOLO_SOURCES = \
|
|||
$(DRAW_SOURCES) \
|
||||
$(TGSIEXEC_SOURCES) \
|
||||
$(TGSIUTIL_SOURCES) \
|
||||
$(PIPEUTIL_SOURCES) \
|
||||
$(STATECACHE_SOURCES) \
|
||||
$(STATETRACKER_SOURCES) \
|
||||
$(TNL_SOURCES) \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue