Merge branch 'upstream-gallium-0.1' into nouveau-gallium-0.1
This commit is contained in:
commit
132def0c41
|
@ -691,35 +691,11 @@ draw_aaline_stage(struct draw_context *draw)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* XXX temporary? solution to mapping a pipe_context to a aaline_stage.
|
||||
*/
|
||||
|
||||
#define MAX_CONTEXTS 10
|
||||
|
||||
static struct pipe_context *Pipe[MAX_CONTEXTS];
|
||||
static struct aaline_stage *Stage[MAX_CONTEXTS];
|
||||
static uint NumContexts;
|
||||
|
||||
static void
|
||||
add_aa_pipe_context(struct pipe_context *pipe, struct aaline_stage *aa)
|
||||
{
|
||||
assert(NumContexts < MAX_CONTEXTS);
|
||||
Pipe[NumContexts] = pipe;
|
||||
Stage[NumContexts] = aa;
|
||||
NumContexts++;
|
||||
}
|
||||
|
||||
static struct aaline_stage *
|
||||
aaline_stage_from_pipe(struct pipe_context *pipe)
|
||||
{
|
||||
uint i;
|
||||
for (i = 0; i < NumContexts; i++) {
|
||||
if (Pipe[i] == pipe)
|
||||
return Stage[i];
|
||||
}
|
||||
assert(0);
|
||||
return NULL;
|
||||
struct draw_context *draw = (struct draw_context *) pipe->draw;
|
||||
return aaline_stage(draw->pipeline.aaline);
|
||||
}
|
||||
|
||||
|
||||
|
@ -802,6 +778,8 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
|
|||
{
|
||||
struct aaline_stage *aaline;
|
||||
|
||||
pipe->draw = (void *) draw;
|
||||
|
||||
/*
|
||||
* Create / install AA line drawing / prim stage
|
||||
*/
|
||||
|
@ -830,6 +808,4 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
|
|||
|
||||
pipe->bind_sampler_state = aaline_bind_sampler_state;
|
||||
pipe->set_sampler_texture = aaline_set_sampler_texture;
|
||||
|
||||
add_aa_pipe_context(pipe, aaline);
|
||||
}
|
||||
|
|
|
@ -762,35 +762,11 @@ draw_aapoint_stage(struct draw_context *draw)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* XXX temporary? solution to mapping a pipe_context to a aapoint_stage.
|
||||
*/
|
||||
|
||||
#define MAX_CONTEXTS 10
|
||||
|
||||
static struct pipe_context *Pipe[MAX_CONTEXTS];
|
||||
static struct aapoint_stage *Stage[MAX_CONTEXTS];
|
||||
static uint NumContexts;
|
||||
|
||||
static void
|
||||
add_aa_pipe_context(struct pipe_context *pipe, struct aapoint_stage *aa)
|
||||
{
|
||||
assert(NumContexts < MAX_CONTEXTS);
|
||||
Pipe[NumContexts] = pipe;
|
||||
Stage[NumContexts] = aa;
|
||||
NumContexts++;
|
||||
}
|
||||
|
||||
static struct aapoint_stage *
|
||||
aapoint_stage_from_pipe(struct pipe_context *pipe)
|
||||
{
|
||||
uint i;
|
||||
for (i = 0; i < NumContexts; i++) {
|
||||
if (Pipe[i] == pipe)
|
||||
return Stage[i];
|
||||
}
|
||||
assert(0);
|
||||
return NULL;
|
||||
struct draw_context *draw = (struct draw_context *) pipe->draw;
|
||||
return aapoint_stage(draw->pipeline.aapoint);
|
||||
}
|
||||
|
||||
|
||||
|
@ -850,6 +826,8 @@ draw_install_aapoint_stage(struct draw_context *draw,
|
|||
{
|
||||
struct aapoint_stage *aapoint;
|
||||
|
||||
pipe->draw = (void *) draw;
|
||||
|
||||
/*
|
||||
* Create / install AA point drawing / prim stage
|
||||
*/
|
||||
|
@ -868,6 +846,4 @@ draw_install_aapoint_stage(struct draw_context *draw,
|
|||
pipe->create_fs_state = aapoint_create_fs_state;
|
||||
pipe->bind_fs_state = aapoint_bind_fs_state;
|
||||
pipe->delete_fs_state = aapoint_delete_fs_state;
|
||||
|
||||
add_aa_pipe_context(pipe, aapoint);
|
||||
}
|
||||
|
|
|
@ -559,35 +559,11 @@ draw_pstip_stage(struct draw_context *draw)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* XXX temporary? solution to mapping a pipe_context to a pstip_stage.
|
||||
*/
|
||||
|
||||
#define MAX_CONTEXTS 10
|
||||
|
||||
static struct pipe_context *Pipe[MAX_CONTEXTS];
|
||||
static struct pstip_stage *Stage[MAX_CONTEXTS];
|
||||
static uint NumContexts;
|
||||
|
||||
static void
|
||||
add_pstip_pipe_context(struct pipe_context *pipe, struct pstip_stage *pstip)
|
||||
{
|
||||
assert(NumContexts < MAX_CONTEXTS);
|
||||
Pipe[NumContexts] = pipe;
|
||||
Stage[NumContexts] = pstip;
|
||||
NumContexts++;
|
||||
}
|
||||
|
||||
static struct pstip_stage *
|
||||
pstip_stage_from_pipe(struct pipe_context *pipe)
|
||||
{
|
||||
uint i;
|
||||
for (i = 0; i < NumContexts; i++) {
|
||||
if (Pipe[i] == pipe)
|
||||
return Stage[i];
|
||||
}
|
||||
assert(0);
|
||||
return NULL;
|
||||
struct draw_context *draw = (struct draw_context *) pipe->draw;
|
||||
return pstip_stage(draw->pipeline.pstipple);
|
||||
}
|
||||
|
||||
|
||||
|
@ -686,6 +662,8 @@ draw_install_pstipple_stage(struct draw_context *draw,
|
|||
{
|
||||
struct pstip_stage *pstip;
|
||||
|
||||
pipe->draw = (void *) draw;
|
||||
|
||||
/*
|
||||
* Create / install AA line drawing / prim stage
|
||||
*/
|
||||
|
@ -716,6 +694,4 @@ draw_install_pstipple_stage(struct draw_context *draw,
|
|||
pipe->bind_sampler_state = pstip_bind_sampler_state;
|
||||
pipe->set_sampler_texture = pstip_set_sampler_texture;
|
||||
pipe->set_polygon_stipple = pstip_set_polygon_stipple;
|
||||
|
||||
add_pstip_pipe_context(pipe, pstip);
|
||||
}
|
||||
|
|
|
@ -101,9 +101,9 @@ static void lines( struct draw_stage *stage,
|
|||
assert(((header->edgeflags & 0x4) >> 2) == header->v[2]->edgeflag);
|
||||
#endif
|
||||
|
||||
if (header->edgeflags & 0x4) line( stage, v2, v0 );
|
||||
if (header->edgeflags & 0x1) line( stage, v0, v1 );
|
||||
if (header->edgeflags & 0x2) line( stage, v1, v2 );
|
||||
if (header->edgeflags & 0x4) line( stage, v2, v0 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
|
|||
if (wide_lines) {
|
||||
draw->pipeline.wide_line->next = next;
|
||||
next = draw->pipeline.wide_line;
|
||||
precalc_flat = 1;
|
||||
}
|
||||
|
||||
if (wide_points || draw->rasterizer->point_sprite) {
|
||||
|
|
|
@ -86,7 +86,10 @@ static void wideline_line( struct draw_stage *stage,
|
|||
|
||||
const float dx = FABSF(pos0[0] - pos2[0]);
|
||||
const float dy = FABSF(pos0[1] - pos2[1]);
|
||||
|
||||
|
||||
/* small tweak to meet GL specification */
|
||||
const float bias = 0.125f;
|
||||
|
||||
/*
|
||||
* Draw wide line as a quad (two tris) by "stretching" the line along
|
||||
* X or Y.
|
||||
|
@ -95,10 +98,10 @@ static void wideline_line( struct draw_stage *stage,
|
|||
|
||||
if (dx > dy) {
|
||||
/* x-major line */
|
||||
pos0[1] = pos0[1] - half_width - 0.25f;
|
||||
pos1[1] = pos1[1] + half_width - 0.25f;
|
||||
pos2[1] = pos2[1] - half_width - 0.25f;
|
||||
pos3[1] = pos3[1] + half_width - 0.25f;
|
||||
pos0[1] = pos0[1] - half_width - bias;
|
||||
pos1[1] = pos1[1] + half_width - bias;
|
||||
pos2[1] = pos2[1] - half_width - bias;
|
||||
pos3[1] = pos3[1] + half_width - bias;
|
||||
if (pos0[0] < pos2[0]) {
|
||||
/* left to right line */
|
||||
pos0[0] -= 0.5f;
|
||||
|
@ -116,10 +119,10 @@ static void wideline_line( struct draw_stage *stage,
|
|||
}
|
||||
else {
|
||||
/* y-major line */
|
||||
pos0[0] = pos0[0] - half_width + 0.25f;
|
||||
pos1[0] = pos1[0] + half_width + 0.25f;
|
||||
pos2[0] = pos2[0] - half_width + 0.25f;
|
||||
pos3[0] = pos3[0] + half_width + 0.25f;
|
||||
pos0[0] = pos0[0] - half_width + bias;
|
||||
pos1[0] = pos1[0] + half_width + bias;
|
||||
pos2[0] = pos2[0] - half_width + bias;
|
||||
pos3[0] = pos3[0] + half_width + bias;
|
||||
if (pos0[1] < pos2[1]) {
|
||||
/* top to bottom line */
|
||||
pos0[1] -= 0.5f;
|
||||
|
|
|
@ -109,7 +109,7 @@ static void widepoint_point( struct draw_stage *stage,
|
|||
const struct widepoint_stage *wide = widepoint_stage(stage);
|
||||
const boolean sprite = (boolean) stage->draw->rasterizer->point_sprite;
|
||||
float half_size;
|
||||
float left_adj, right_adj;
|
||||
float left_adj, right_adj, bot_adj, top_adj;
|
||||
|
||||
struct prim_header tri;
|
||||
|
||||
|
@ -124,6 +124,8 @@ static void widepoint_point( struct draw_stage *stage,
|
|||
float *pos2 = v2->data[0];
|
||||
float *pos3 = v3->data[0];
|
||||
|
||||
const float xbias = 0.0, ybias = -0.125;
|
||||
|
||||
/* point size is either per-vertex or fixed size */
|
||||
if (wide->psize_slot >= 0) {
|
||||
half_size = 0.5f * header->v[0]->data[wide->psize_slot][0];
|
||||
|
@ -132,20 +134,22 @@ static void widepoint_point( struct draw_stage *stage,
|
|||
half_size = wide->half_point_size;
|
||||
}
|
||||
|
||||
left_adj = -half_size; /* + 0.25f;*/
|
||||
right_adj = half_size; /* + 0.25f;*/
|
||||
left_adj = -half_size + xbias;
|
||||
right_adj = half_size + xbias;
|
||||
bot_adj = half_size + ybias;
|
||||
top_adj = -half_size + ybias;
|
||||
|
||||
pos0[0] += left_adj;
|
||||
pos0[1] -= half_size;
|
||||
pos0[1] += top_adj;
|
||||
|
||||
pos1[0] += left_adj;
|
||||
pos1[1] += half_size;
|
||||
pos1[1] += bot_adj;
|
||||
|
||||
pos2[0] += right_adj;
|
||||
pos2[1] -= half_size;
|
||||
pos2[1] += top_adj;
|
||||
|
||||
pos3[0] += right_adj;
|
||||
pos3[1] += half_size;
|
||||
pos3[1] += bot_adj;
|
||||
|
||||
if (sprite) {
|
||||
static const float tex00[4] = { 0, 0, 0, 1 };
|
||||
|
|
|
@ -697,3 +697,127 @@ pipe_put_tile_rgba(struct pipe_context *pipe,
|
|||
|
||||
FREE(packed);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a block of Z values, converted to 32-bit range.
|
||||
*/
|
||||
void
|
||||
pipe_get_tile_z(struct pipe_context *pipe,
|
||||
struct pipe_surface *ps,
|
||||
uint x, uint y, uint w, uint h,
|
||||
uint *z)
|
||||
{
|
||||
const uint dstStride = w;
|
||||
uint *pDest = z;
|
||||
uint i, j;
|
||||
|
||||
if (pipe_clip_tile(x, y, &w, &h, ps))
|
||||
return;
|
||||
|
||||
switch (ps->format) {
|
||||
case PIPE_FORMAT_Z32_UNORM:
|
||||
{
|
||||
const uint *pSrc
|
||||
= (const uint *) pipe_surface_map(ps) + (y * ps->pitch + x);
|
||||
for (i = 0; i < h; i++) {
|
||||
memcpy(pDest, pSrc, 4 * w);
|
||||
pDest += dstStride;
|
||||
pSrc += ps->pitch;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
{
|
||||
const uint *pSrc
|
||||
= (const uint *) pipe_surface_map(ps) + (y * ps->pitch + x);
|
||||
for (i = 0; i < h; i++) {
|
||||
for (j = 0; j < w; j++) {
|
||||
/* convert 24-bit Z to 32-bit Z */
|
||||
pDest[j] = (pSrc[j] << 8) | (pSrc[j] & 0xff);
|
||||
}
|
||||
pDest += dstStride;
|
||||
pSrc += ps->pitch;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_Z16_UNORM:
|
||||
{
|
||||
const ushort *pSrc
|
||||
= (const ushort *) pipe_surface_map(ps) + (y * ps->pitch + x);
|
||||
for (i = 0; i < h; i++) {
|
||||
for (j = 0; j < w; j++) {
|
||||
/* convert 16-bit Z to 32-bit Z */
|
||||
pDest[j] = (pSrc[j] << 16) | pSrc[j];
|
||||
}
|
||||
pDest += dstStride;
|
||||
pSrc += ps->pitch;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
pipe_surface_unmap(ps);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
pipe_put_tile_z(struct pipe_context *pipe,
|
||||
struct pipe_surface *ps,
|
||||
uint x, uint y, uint w, uint h,
|
||||
const uint *zSrc)
|
||||
{
|
||||
const uint srcStride = w;
|
||||
const uint *pSrc = zSrc;
|
||||
uint i, j;
|
||||
|
||||
if (pipe_clip_tile(x, y, &w, &h, ps))
|
||||
return;
|
||||
|
||||
switch (ps->format) {
|
||||
case PIPE_FORMAT_Z32_UNORM:
|
||||
{
|
||||
uint *pDest = (uint *) pipe_surface_map(ps) + (y * ps->pitch + x);
|
||||
for (i = 0; i < h; i++) {
|
||||
memcpy(pDest, pSrc, 4 * w);
|
||||
pDest += ps->pitch;
|
||||
pSrc += srcStride;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
{
|
||||
uint *pDest = (uint *) pipe_surface_map(ps) + (y * ps->pitch + x);
|
||||
for (i = 0; i < h; i++) {
|
||||
for (j = 0; j < w; j++) {
|
||||
/* convert 32-bit Z to 24-bit Z (0 stencil) */
|
||||
pDest[j] = pSrc[j] >> 8;
|
||||
}
|
||||
pDest += ps->pitch;
|
||||
pSrc += srcStride;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_Z16_UNORM:
|
||||
{
|
||||
ushort *pDest = (ushort *) pipe_surface_map(ps) + (y * ps->pitch + x);
|
||||
for (i = 0; i < h; i++) {
|
||||
for (j = 0; j < w; j++) {
|
||||
/* convert 32-bit Z to 16-bit Z */
|
||||
pDest[j] = pSrc[j] >> 16;
|
||||
}
|
||||
pDest += ps->pitch;
|
||||
pSrc += srcStride;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
||||
pipe_surface_unmap(ps);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -78,4 +78,18 @@ pipe_put_tile_rgba(struct pipe_context *pipe,
|
|||
uint x, uint y, uint w, uint h,
|
||||
const float *p);
|
||||
|
||||
|
||||
extern void
|
||||
pipe_get_tile_z(struct pipe_context *pipe,
|
||||
struct pipe_surface *ps,
|
||||
uint x, uint y, uint w, uint h,
|
||||
uint *z);
|
||||
|
||||
extern void
|
||||
pipe_put_tile_z(struct pipe_context *pipe,
|
||||
struct pipe_surface *ps,
|
||||
uint x, uint y, uint w, uint h,
|
||||
const uint *z);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,6 +28,7 @@ softpipe = env.ConvenienceLibrary(
|
|||
'sp_quad_stencil.c',
|
||||
'sp_quad_stipple.c',
|
||||
'sp_query.c',
|
||||
'sp_screen.c',
|
||||
'sp_state_blend.c',
|
||||
'sp_state_clip.c',
|
||||
'sp_state_derived.c',
|
||||
|
|
|
@ -56,6 +56,7 @@ struct pipe_context {
|
|||
struct pipe_screen *screen;
|
||||
|
||||
void *priv; /** context private data (for DRI for example) */
|
||||
void *draw; /** private, for draw module (temporary? */
|
||||
|
||||
void (*destroy)( struct pipe_context * );
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ update_textures(struct st_context *st)
|
|||
const GLuint su = fprog->Base.SamplerUnits[unit];
|
||||
struct gl_texture_object *texObj = st->ctx->Texture.Unit[su]._Current;
|
||||
struct st_texture_object *stObj = st_texture_object(texObj);
|
||||
struct pipe_texture *pt;
|
||||
|
||||
if (texObj) {
|
||||
GLboolean flush, retval;
|
||||
|
@ -67,16 +68,15 @@ update_textures(struct st_context *st)
|
|||
* this table before being deleted, otherwise the pointer
|
||||
* comparison below could fail.
|
||||
*/
|
||||
if (st->state.sampler_texture[unit] != stObj) {
|
||||
struct pipe_texture *pt = st_get_stobj_texture(stObj);
|
||||
st->state.sampler_texture[unit] = stObj;
|
||||
|
||||
pt = st_get_stobj_texture(stObj);
|
||||
|
||||
if (st->state.sampler_texture[unit] != pt) {
|
||||
st->state.sampler_texture[unit] = pt;
|
||||
st->pipe->set_sampler_texture(st->pipe, unit, pt);
|
||||
}
|
||||
|
||||
stObj = st->state.sampler_texture[unit];
|
||||
|
||||
if (stObj && stObj->dirtyData) {
|
||||
struct pipe_texture *pt = st_get_stobj_texture(stObj);
|
||||
st->pipe->texture_update(st->pipe, pt);
|
||||
stObj->dirtyData = GL_FALSE;
|
||||
}
|
||||
|
|
|
@ -727,8 +727,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
|
|||
pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data);
|
||||
pipe->bind_fs_state(pipe, ctx->st->state.fs->data);
|
||||
pipe->bind_vs_state(pipe, ctx->st->state.vs->cso->data);
|
||||
pipe->set_sampler_texture(pipe, unit,
|
||||
st_get_stobj_texture(ctx->st->state.sampler_texture[unit]));
|
||||
pipe->set_sampler_texture(pipe, unit, ctx->st->state.sampler_texture[unit]);
|
||||
pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]->data);
|
||||
pipe->set_viewport_state(pipe, &ctx->st->state.viewport);
|
||||
}
|
||||
|
@ -1299,7 +1298,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
|
|||
psRead,
|
||||
srcx, srcy, width, height);
|
||||
}
|
||||
else {
|
||||
else if (type == GL_COLOR) {
|
||||
/* alternate path using get/put_tile() */
|
||||
GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
|
||||
|
||||
|
@ -1308,6 +1307,13 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
|
|||
|
||||
free(buf);
|
||||
}
|
||||
else {
|
||||
/* GL_DEPTH */
|
||||
GLuint *buf = (GLuint *) malloc(width * height * sizeof(GLuint));
|
||||
pipe_get_tile_z(pipe, psRead, srcx, srcy, width, height, buf);
|
||||
pipe_put_tile_z(pipe, psTex, 0, 0, width, height, buf);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
/* draw textured quad */
|
||||
draw_textured_quad(ctx, dstx, dsty, ctx->Current.RasterPos[2],
|
||||
|
|
|
@ -86,7 +86,7 @@ struct st_context
|
|||
struct pipe_clip_state clip;
|
||||
struct pipe_constant_buffer constants[2];
|
||||
struct pipe_framebuffer_state framebuffer;
|
||||
struct st_texture_object *sampler_texture[PIPE_MAX_SAMPLERS];
|
||||
struct pipe_texture *sampler_texture[PIPE_MAX_SAMPLERS];
|
||||
struct pipe_poly_stipple poly_stipple;
|
||||
struct pipe_scissor_state scissor;
|
||||
struct pipe_viewport_state viewport;
|
||||
|
|
|
@ -312,8 +312,7 @@ st_render_mipmap(struct st_context *st,
|
|||
pipe->bind_vs_state(pipe, st->state.vs->cso->data);
|
||||
if (st->state.sampler[0])
|
||||
pipe->bind_sampler_state(pipe, 0, st->state.sampler[0]->data);
|
||||
pipe->set_sampler_texture(pipe, 0,
|
||||
st_get_stobj_texture(st->state.sampler_texture[0]));
|
||||
pipe->set_sampler_texture(pipe, 0, st->state.sampler_texture[0]);
|
||||
pipe->set_viewport_state(pipe, &st->state.viewport);
|
||||
|
||||
return TRUE;
|
||||
|
|
Loading…
Reference in New Issue