Merge branch 'upstream-gallium-0.1' into darktama-gallium-0.1

This commit is contained in:
Ben Skeggs
2007-12-18 11:02:46 +11:00
52 changed files with 1433 additions and 900 deletions
+169
View File
@@ -0,0 +1,169 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define GL_GLEXT_PROTOTYPES
#include <GL/glut.h>
#include <unistd.h>
#include <signal.h>
unsigned show_fps = 0;
unsigned int frame_cnt = 0;
void alarmhandler(int);
static const char *filename = NULL;
static void usage(char *name)
{
fprintf(stderr, "usage: %s [ options ] shader_filename\n", name);
fprintf(stderr, "\n" );
fprintf(stderr, "options:\n");
fprintf(stderr, " -fps show frames per second\n");
}
void alarmhandler (int sig)
{
if (sig == SIGALRM) {
printf("%d frames in 5.0 seconds = %.3f FPS\n", frame_cnt,
frame_cnt / 5.0);
frame_cnt = 0;
}
signal(SIGALRM, alarmhandler);
alarm(5);
}
static void args(int argc, char *argv[])
{
GLint i;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-fps") == 0) {
show_fps = 1;
}
else if (i == argc - 1) {
filename = argv[i];
}
else {
usage(argv[0]);
exit(1);
}
}
if (!filename) {
usage(argv[0]);
exit(1);
}
}
static void Init( void )
{
GLint errno;
GLuint prognum;
char buf[4096];
GLuint sz;
FILE *f;
if ((f = fopen(filename, "r")) == NULL) {
fprintf(stderr, "Couldn't open %s\n", filename);
exit(1);
}
sz = fread(buf, 1, sizeof(buf), f);
if (!feof(f)) {
fprintf(stderr, "file too long\n");
exit(1);
}
fprintf(stderr, "%.*s\n", sz, buf);
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
printf("Error: GL_ARB_fragment_program not supported!\n");
exit(1);
}
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
/* Setup the fragment program */
glGenProgramsARB(1, &prognum);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prognum);
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
sz, (const GLubyte *)buf);
errno = glGetError();
printf("glGetError = 0x%x\n", errno);
if (errno != GL_NO_ERROR) {
GLint errorpos;
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
printf("errorpos: %d\n", errorpos);
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
}
glEnable(GL_FRAGMENT_PROGRAM_ARB);
glClearColor(.3, .3, .3, 0);
}
static void Reshape(int width, int height)
{
glViewport(0, 0, (GLint)width, (GLint)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
glMatrixMode(GL_MODELVIEW);
}
static void Key(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(1);
default:
return;
}
glutPostRedisplay();
}
static void Display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glColor3f(0,0,1);
glVertex3f( 0.9, -0.9, -30.0);
glColor3f(1,0,0);
glVertex3f( 0.9, 0.9, -30.0);
glColor3f(0,1,0);
glVertex3f(-0.9, 0.0, -30.0);
glEnd();
glFlush();
if (show_fps) {
++frame_cnt;
glutPostRedisplay();
}
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitWindowPosition(0, 0);
glutInitWindowSize(250, 250);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH);
glutCreateWindow(argv[0]);
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutDisplayFunc(Display);
args(argc, argv);
Init();
if (show_fps) {
signal(SIGALRM, alarmhandler);
alarm(5);
}
glutMainLoop();
return 0;
}
+3 -7
View File
@@ -176,10 +176,6 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws)
/* state setters */
cell->pipe.create_alpha_test_state = cell_create_alpha_test_state;
cell->pipe.bind_alpha_test_state = cell_bind_alpha_test_state;
cell->pipe.delete_alpha_test_state = cell_delete_alpha_test_state;
cell->pipe.create_blend_state = cell_create_blend_state;
cell->pipe.bind_blend_state = cell_bind_blend_state;
cell->pipe.delete_blend_state = cell_delete_blend_state;
@@ -188,9 +184,9 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws)
cell->pipe.bind_sampler_state = cell_bind_sampler_state;
cell->pipe.delete_sampler_state = cell_delete_sampler_state;
cell->pipe.create_depth_stencil_state = cell_create_depth_stencil_state;
cell->pipe.bind_depth_stencil_state = cell_bind_depth_stencil_state;
cell->pipe.delete_depth_stencil_state = cell_delete_depth_stencil_state;
cell->pipe.create_depth_stencil_alpha_state = cell_create_depth_stencil_alpha_state;
cell->pipe.bind_depth_stencil_alpha_state = cell_bind_depth_stencil_alpha_state;
cell->pipe.delete_depth_stencil_alpha_state = cell_delete_depth_stencil_alpha_state;
cell->pipe.create_rasterizer_state = cell_create_rasterizer_state;
cell->pipe.bind_rasterizer_state = cell_bind_rasterizer_state;
+1 -2
View File
@@ -40,10 +40,9 @@ struct cell_context
struct cell_winsys *winsys;
const struct pipe_alpha_test_state *alpha_test;
const struct pipe_blend_state *blend;
const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
const struct pipe_depth_stencil_state *depth_stencil;
const struct pipe_depth_stencil_alpha_state *depth_stencil;
const struct pipe_rasterizer_state *rasterizer;
struct pipe_blend_color blend_color;
+4 -11
View File
@@ -27,13 +27,6 @@ cell_set_framebuffer_state( struct pipe_context *,
const struct pipe_framebuffer_state * );
extern void *
cell_create_alpha_test_state(struct pipe_context *,
const struct pipe_alpha_test_state *);
extern void
cell_bind_alpha_test_state(struct pipe_context *, void *);
extern void
cell_delete_alpha_test_state(struct pipe_context *, void *);
extern void *
cell_create_blend_state(struct pipe_context *, const struct pipe_blend_state *);
@@ -56,14 +49,14 @@ cell_delete_sampler_state(struct pipe_context *, void *);
extern void *
cell_create_depth_stencil_state(struct pipe_context *,
const struct pipe_depth_stencil_state *);
cell_create_depth_stencil_alpha_state(struct pipe_context *,
const struct pipe_depth_stencil_alpha_state *);
extern void
cell_bind_depth_stencil_state(struct pipe_context *, void *);
cell_bind_depth_stencil_alpha_state(struct pipe_context *, void *);
extern void
cell_delete_depth_stencil_state(struct pipe_context *, void *);
cell_delete_depth_stencil_alpha_state(struct pipe_context *, void *);
void *cell_create_fs_state(struct pipe_context *,
+9 -39
View File
@@ -69,60 +69,30 @@ void cell_set_blend_color( struct pipe_context *pipe,
}
/** XXX move someday? Or consolidate all these simple state setters
* into one file.
*/
void *
cell_create_alpha_test_state(struct pipe_context *pipe,
const struct pipe_alpha_test_state *alpha)
cell_create_depth_stencil_alpha_state(struct pipe_context *pipe,
const struct pipe_depth_stencil_alpha_state *depth_stencil)
{
struct pipe_alpha_test_state *state = MALLOC( sizeof(struct pipe_alpha_test_state) );
memcpy(state, alpha, sizeof(struct pipe_alpha_test_state));
struct pipe_depth_stencil_alpha_state *state =
MALLOC( sizeof(struct pipe_depth_stencil_alpha_state) );
memcpy(state, depth_stencil, sizeof(struct pipe_depth_stencil_alpha_state));
return state;
}
void
cell_bind_alpha_test_state(struct pipe_context *pipe,
void *alpha)
cell_bind_depth_stencil_alpha_state(struct pipe_context *pipe,
void *depth_stencil)
{
struct cell_context *cell = cell_context(pipe);
cell->alpha_test = (const struct pipe_alpha_test_state *)alpha;
cell->dirty |= CELL_NEW_ALPHA_TEST;
}
void
cell_delete_alpha_test_state(struct pipe_context *pipe,
void *alpha)
{
FREE( alpha );
}
void *
cell_create_depth_stencil_state(struct pipe_context *pipe,
const struct pipe_depth_stencil_state *depth_stencil)
{
struct pipe_depth_stencil_state *state =
MALLOC( sizeof(struct pipe_depth_stencil_state) );
memcpy(state, depth_stencil, sizeof(struct pipe_depth_stencil_state));
return state;
}
void
cell_bind_depth_stencil_state(struct pipe_context *pipe,
void *depth_stencil)
{
struct cell_context *cell = cell_context(pipe);
cell->depth_stencil = (const struct pipe_depth_stencil_state *)depth_stencil;
cell->depth_stencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil;
cell->dirty |= CELL_NEW_DEPTH_STENCIL;
}
void
cell_delete_depth_stencil_state(struct pipe_context *pipe, void *depth)
cell_delete_depth_stencil_alpha_state(struct pipe_context *pipe, void *depth)
{
FREE( depth );
}
+3 -10
View File
@@ -78,7 +78,7 @@ static struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_
case CSO_SAMPLER:
hash = sc->sampler_hash;
break;
case CSO_DEPTH_STENCIL:
case CSO_DEPTH_STENCIL_ALPHA:
hash = sc->depth_stencil_hash;
break;
case CSO_RASTERIZER:
@@ -90,9 +90,6 @@ static struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_
case CSO_VERTEX_SHADER:
hash = sc->vs_hash;
break;
case CSO_ALPHA_TEST:
hash = sc->alpha_hash;
break;
}
return hash;
@@ -105,16 +102,14 @@ static int _cso_size_for_type(enum cso_cache_type type)
return sizeof(struct pipe_blend_state);
case CSO_SAMPLER:
return sizeof(struct pipe_sampler_state);
case CSO_DEPTH_STENCIL:
return sizeof(struct pipe_depth_stencil_state);
case CSO_DEPTH_STENCIL_ALPHA:
return sizeof(struct pipe_depth_stencil_alpha_state);
case CSO_RASTERIZER:
return sizeof(struct pipe_rasterizer_state);
case CSO_FRAGMENT_SHADER:
return sizeof(struct pipe_shader_state);
case CSO_VERTEX_SHADER:
return sizeof(struct pipe_shader_state);
case CSO_ALPHA_TEST:
return sizeof(struct pipe_alpha_test_state);
}
return 0;
}
@@ -169,7 +164,6 @@ struct cso_cache *cso_cache_create(void)
sc->rasterizer_hash = cso_hash_create();
sc->fs_hash = cso_hash_create();
sc->vs_hash = cso_hash_create();
sc->alpha_hash = cso_hash_create();
return sc;
}
@@ -183,6 +177,5 @@ void cso_cache_delete(struct cso_cache *sc)
cso_hash_delete(sc->rasterizer_hash);
cso_hash_delete(sc->fs_hash);
cso_hash_delete(sc->vs_hash);
cso_hash_delete(sc->alpha_hash);
free(sc);
}
+4 -10
View File
@@ -40,7 +40,6 @@
struct cso_hash;
struct cso_cache {
struct cso_hash *alpha_hash;
struct cso_hash *blend_hash;
struct cso_hash *depth_stencil_hash;
struct cso_hash *fs_hash;
@@ -54,8 +53,8 @@ struct cso_blend {
void *data;
};
struct cso_depth_stencil {
struct pipe_depth_stencil_state state;
struct cso_depth_stencil_alpha {
struct pipe_depth_stencil_alpha_state state;
void *data;
};
@@ -79,19 +78,14 @@ struct cso_sampler {
void *data;
};
struct cso_alpha_test {
struct pipe_alpha_test_state state;
void *data;
};
enum cso_cache_type {
CSO_BLEND,
CSO_SAMPLER,
CSO_DEPTH_STENCIL,
CSO_DEPTH_STENCIL_ALPHA,
CSO_RASTERIZER,
CSO_FRAGMENT_SHADER,
CSO_VERTEX_SHADER,
CSO_ALPHA_TEST
CSO_VERTEX_SHADER
};
unsigned cso_construct_key(void *item, int item_size);
-1
View File
@@ -70,7 +70,6 @@ struct failover_context {
/* The most recent drawing state as set by the driver:
*/
const struct fo_state *alpha_test;
const struct fo_state *blend;
const struct fo_state *sampler[PIPE_MAX_SAMPLERS];
const struct fo_state *depth_stencil;
+9 -51
View File
@@ -45,45 +45,6 @@
* lower overheads.
*/
static void *
failover_create_alpha_test_state(struct pipe_context *pipe,
const struct pipe_alpha_test_state *templ)
{
struct fo_state *state = malloc(sizeof(struct fo_state));
struct failover_context *failover = failover_context(pipe);
state->sw_state = failover->sw->create_alpha_test_state(pipe, templ);
state->hw_state = failover->hw->create_alpha_test_state(pipe, templ);
return state;
}
static void
failover_bind_alpha_test_state(struct pipe_context *pipe,
void *alpha)
{
struct failover_context *failover = failover_context(pipe);
struct fo_state *state = (struct fo_state *)alpha;
failover->alpha_test = state;
failover->dirty |= FO_NEW_ALPHA_TEST;
failover->hw->bind_alpha_test_state(failover->hw,
state->hw_state);
}
static void
failover_delete_alpha_test_state(struct pipe_context *pipe,
void *alpha)
{
struct fo_state *state = (struct fo_state*)alpha;
struct failover_context *failover = failover_context(pipe);
failover->sw->delete_alpha_test_state(pipe, state->sw_state);
failover->hw->delete_alpha_test_state(pipe, state->hw_state);
state->sw_state = 0;
state->hw_state = 0;
free(state);
}
static void *
@@ -149,13 +110,13 @@ failover_set_clip_state( struct pipe_context *pipe,
static void *
failover_create_depth_stencil_state(struct pipe_context *pipe,
const struct pipe_depth_stencil_state *templ)
const struct pipe_depth_stencil_alpha_state *templ)
{
struct fo_state *state = malloc(sizeof(struct fo_state));
struct failover_context *failover = failover_context(pipe);
state->sw_state = failover->sw->create_depth_stencil_state(pipe, templ);
state->hw_state = failover->hw->create_depth_stencil_state(pipe, templ);
state->sw_state = failover->sw->create_depth_stencil_alpha_state(pipe, templ);
state->hw_state = failover->hw->create_depth_stencil_alpha_state(pipe, templ);
return state;
}
@@ -168,7 +129,7 @@ failover_bind_depth_stencil_state(struct pipe_context *pipe,
struct fo_state *state = (struct fo_state *)depth_stencil;
failover->depth_stencil = state;
failover->dirty |= FO_NEW_DEPTH_STENCIL;
failover->hw->bind_depth_stencil_state(failover->hw, state->hw_state);
failover->hw->bind_depth_stencil_alpha_state(failover->hw, state->hw_state);
}
static void
@@ -178,8 +139,8 @@ failover_delete_depth_stencil_state(struct pipe_context *pipe,
struct fo_state *state = (struct fo_state*)ds;
struct failover_context *failover = failover_context(pipe);
failover->sw->delete_depth_stencil_state(pipe, state->sw_state);
failover->hw->delete_depth_stencil_state(pipe, state->hw_state);
failover->sw->delete_depth_stencil_alpha_state(pipe, state->sw_state);
failover->hw->delete_depth_stencil_alpha_state(pipe, state->hw_state);
state->sw_state = 0;
state->hw_state = 0;
free(state);
@@ -434,18 +395,15 @@ failover_set_vertex_element(struct pipe_context *pipe,
void
failover_init_state_functions( struct failover_context *failover )
{
failover->pipe.create_alpha_test_state = failover_create_alpha_test_state;
failover->pipe.bind_alpha_test_state = failover_bind_alpha_test_state;
failover->pipe.delete_alpha_test_state = failover_delete_alpha_test_state;
failover->pipe.create_blend_state = failover_create_blend_state;
failover->pipe.bind_blend_state = failover_bind_blend_state;
failover->pipe.delete_blend_state = failover_delete_blend_state;
failover->pipe.create_sampler_state = failover_create_sampler_state;
failover->pipe.bind_sampler_state = failover_bind_sampler_state;
failover->pipe.delete_sampler_state = failover_delete_sampler_state;
failover->pipe.create_depth_stencil_state = failover_create_depth_stencil_state;
failover->pipe.bind_depth_stencil_state = failover_bind_depth_stencil_state;
failover->pipe.delete_depth_stencil_state = failover_delete_depth_stencil_state;
failover->pipe.create_depth_stencil_alpha_state = failover_create_depth_stencil_state;
failover->pipe.bind_depth_stencil_alpha_state = failover_bind_depth_stencil_state;
failover->pipe.delete_depth_stencil_alpha_state = failover_delete_depth_stencil_state;
failover->pipe.create_rasterizer_state = failover_create_rasterizer_state;
failover->pipe.bind_rasterizer_state = failover_bind_rasterizer_state;
failover->pipe.delete_rasterizer_state = failover_delete_rasterizer_state;
+2 -6
View File
@@ -55,10 +55,6 @@ failover_state_emit( struct failover_context *failover )
{
unsigned i;
if (failover->dirty & FO_NEW_ALPHA_TEST)
failover->sw->bind_alpha_test_state( failover->sw,
failover->alpha_test->sw_state );
if (failover->dirty & FO_NEW_BLEND)
failover->sw->bind_blend_state( failover->sw,
failover->blend->sw_state );
@@ -70,8 +66,8 @@ failover_state_emit( struct failover_context *failover )
failover->sw->set_clip_state( failover->sw, &failover->clip );
if (failover->dirty & FO_NEW_DEPTH_STENCIL)
failover->sw->bind_depth_stencil_state( failover->sw,
failover->depth_stencil->sw_state );
failover->sw->bind_depth_stencil_alpha_state( failover->sw,
failover->depth_stencil->sw_state );
if (failover->dirty & FO_NEW_FRAMEBUFFER)
failover->sw->set_framebuffer_state( failover->sw, &failover->framebuffer );
-4
View File
@@ -146,9 +146,6 @@ struct i915_sampler_state {
const struct pipe_sampler_state *templ;
};
struct i915_alpha_test_state {
unsigned LIS6;
};
struct i915_texture {
struct pipe_texture base;
@@ -186,7 +183,6 @@ struct i915_context
/* The most recent drawing state as set by the driver:
*/
const struct i915_alpha_test_state *alpha_test;
const struct i915_blend_state *blend;
const struct i915_sampler_state *sampler[PIPE_MAX_SAMPLERS];
const struct i915_depth_stencil_state *depth_stencil;
+29 -57
View File
@@ -284,13 +284,13 @@ static void i915_delete_sampler_state(struct pipe_context *pipe,
static void *
i915_create_depth_stencil_state(struct pipe_context *pipe,
const struct pipe_depth_stencil_state *depth_stencil)
const struct pipe_depth_stencil_alpha_state *depth_stencil)
{
struct i915_depth_stencil_state *cso = CALLOC_STRUCT( i915_depth_stencil_state );
{
int testmask = depth_stencil->stencil.value_mask[0] & 0xff;
int writemask = depth_stencil->stencil.write_mask[0] & 0xff;
int testmask = depth_stencil->stencil[0].value_mask & 0xff;
int writemask = depth_stencil->stencil[0].write_mask & 0xff;
cso->stencil_modes4 |= (_3DSTATE_MODES_4_CMD |
ENABLE_STENCIL_TEST_MASK |
@@ -299,12 +299,12 @@ i915_create_depth_stencil_state(struct pipe_context *pipe,
STENCIL_WRITE_MASK(writemask));
}
if (depth_stencil->stencil.front_enabled) {
int test = i915_translate_compare_func(depth_stencil->stencil.front_func);
int fop = i915_translate_stencil_op(depth_stencil->stencil.front_fail_op);
int dfop = i915_translate_stencil_op(depth_stencil->stencil.front_zfail_op);
int dpop = i915_translate_stencil_op(depth_stencil->stencil.front_zpass_op);
int ref = depth_stencil->stencil.ref_value[0] & 0xff;
if (depth_stencil->stencil[0].enabled) {
int test = i915_translate_compare_func(depth_stencil->stencil[0].func);
int fop = i915_translate_stencil_op(depth_stencil->stencil[0].fail_op);
int dfop = i915_translate_stencil_op(depth_stencil->stencil[0].zfail_op);
int dpop = i915_translate_stencil_op(depth_stencil->stencil[0].zpass_op);
int ref = depth_stencil->stencil[0].ref_value & 0xff;
cso->stencil_LIS5 |= (S5_STENCIL_TEST_ENABLE |
S5_STENCIL_WRITE_ENABLE |
@@ -315,14 +315,14 @@ i915_create_depth_stencil_state(struct pipe_context *pipe,
(dpop << S5_STENCIL_PASS_Z_PASS_SHIFT));
}
if (depth_stencil->stencil.back_enabled) {
int test = i915_translate_compare_func(depth_stencil->stencil.back_func);
int fop = i915_translate_stencil_op(depth_stencil->stencil.back_fail_op);
int dfop = i915_translate_stencil_op(depth_stencil->stencil.back_zfail_op);
int dpop = i915_translate_stencil_op(depth_stencil->stencil.back_zpass_op);
int ref = depth_stencil->stencil.ref_value[1] & 0xff;
int tmask = depth_stencil->stencil.value_mask[1] & 0xff;
int wmask = depth_stencil->stencil.write_mask[1] & 0xff;
if (depth_stencil->stencil[1].enabled) {
int test = i915_translate_compare_func(depth_stencil->stencil[1].func);
int fop = i915_translate_stencil_op(depth_stencil->stencil[1].fail_op);
int dfop = i915_translate_stencil_op(depth_stencil->stencil[1].zfail_op);
int dpop = i915_translate_stencil_op(depth_stencil->stencil[1].zpass_op);
int ref = depth_stencil->stencil[1].ref_value & 0xff;
int tmask = depth_stencil->stencil[1].value_mask & 0xff;
int wmask = depth_stencil->stencil[1].write_mask & 0xff;
cso->bfo[0] = (_3DSTATE_BACKFACE_STENCIL_OPS |
BFO_ENABLE_STENCIL_FUNCS |
@@ -363,6 +363,15 @@ i915_create_depth_stencil_state(struct pipe_context *pipe,
cso->depth_LIS6 |= S6_DEPTH_WRITE_ENABLE;
}
if (depth_stencil->alpha.enabled) {
int test = i915_translate_compare_func(depth_stencil->alpha.func);
ubyte refByte = float_to_ubyte(depth_stencil->alpha.ref);
cso->depth_LIS6 |= (S6_ALPHA_TEST_ENABLE |
(test << S6_ALPHA_TEST_FUNC_SHIFT) |
(((unsigned) refByte) << S6_ALPHA_REF_SHIFT));
}
return cso;
}
@@ -383,39 +392,6 @@ static void i915_delete_depth_stencil_state(struct pipe_context *pipe,
}
static void *
i915_create_alpha_test_state(struct pipe_context *pipe,
const struct pipe_alpha_test_state *alpha_test)
{
struct i915_alpha_test_state *cso = CALLOC_STRUCT( i915_alpha_test_state );
if (alpha_test->enabled) {
int test = i915_translate_compare_func(alpha_test->func);
ubyte refByte = float_to_ubyte(alpha_test->ref);
cso->LIS6 |= (S6_ALPHA_TEST_ENABLE |
(test << S6_ALPHA_TEST_FUNC_SHIFT) |
(((unsigned) refByte) << S6_ALPHA_REF_SHIFT));
}
return cso;
}
static void i915_bind_alpha_test_state(struct pipe_context *pipe,
void *alpha)
{
struct i915_context *i915 = i915_context(pipe);
i915->alpha_test = (const struct i915_alpha_test_state*)alpha;
i915->dirty |= I915_NEW_ALPHA_TEST;
}
static void i915_delete_alpha_test_state(struct pipe_context *pipe,
void *alpha)
{
FREE(alpha);
}
static void i915_set_scissor_state( struct pipe_context *pipe,
const struct pipe_scissor_state *scissor )
{
@@ -674,10 +650,6 @@ static void i915_set_vertex_element( struct pipe_context *pipe,
void
i915_init_state_functions( struct i915_context *i915 )
{
i915->pipe.create_alpha_test_state = i915_create_alpha_test_state;
i915->pipe.bind_alpha_test_state = i915_bind_alpha_test_state;
i915->pipe.delete_alpha_test_state = i915_delete_alpha_test_state;
i915->pipe.create_blend_state = i915_create_blend_state;
i915->pipe.bind_blend_state = i915_bind_blend_state;
i915->pipe.delete_blend_state = i915_delete_blend_state;
@@ -686,9 +658,9 @@ i915_init_state_functions( struct i915_context *i915 )
i915->pipe.bind_sampler_state = i915_bind_sampler_state;
i915->pipe.delete_sampler_state = i915_delete_sampler_state;
i915->pipe.create_depth_stencil_state = i915_create_depth_stencil_state;
i915->pipe.bind_depth_stencil_state = i915_bind_depth_stencil_state;
i915->pipe.delete_depth_stencil_state = i915_delete_depth_stencil_state;
i915->pipe.create_depth_stencil_alpha_state = i915_create_depth_stencil_state;
i915->pipe.bind_depth_stencil_alpha_state = i915_bind_depth_stencil_state;
i915->pipe.delete_depth_stencil_alpha_state = i915_delete_depth_stencil_state;
i915->pipe.create_rasterizer_state = i915_create_rasterizer_state;
i915->pipe.bind_rasterizer_state = i915_bind_rasterizer_state;
@@ -159,10 +159,6 @@ static void upload_S6( struct i915_context *i915 )
unsigned LIS6 = (S6_COLOR_WRITE_ENABLE |
(2 << S6_TRISTRIP_PV_SHIFT));
/* I915_NEW_ALPHA_TEST
*/
LIS6 |= i915->alpha_test->LIS6;
/* I915_NEW_BLEND
*/
LIS6 |= i915->blend->LIS6;
@@ -178,7 +174,7 @@ static void upload_S6( struct i915_context *i915 )
}
const struct i915_tracked_state i915_upload_S6 = {
I915_NEW_ALPHA_TEST | I915_NEW_BLEND | I915_NEW_DEPTH_STENCIL,
I915_NEW_BLEND | I915_NEW_DEPTH_STENCIL,
upload_S6
};
+20 -106
View File
@@ -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"
/*
@@ -158,21 +76,18 @@ i915_get_tex_surface(struct pipe_context *pipe,
}
/*
* XXX Move this into core Mesa?
*/
static void
_mesa_copy_rect(ubyte * dst,
unsigned cpp,
unsigned dst_pitch,
unsigned dst_x,
unsigned dst_y,
unsigned width,
unsigned height,
const ubyte * src,
unsigned src_pitch,
unsigned src_x,
unsigned src_y)
copy_rect(ubyte * dst,
unsigned cpp,
unsigned dst_pitch,
unsigned dst_x,
unsigned dst_y,
unsigned width,
unsigned height,
const ubyte *src,
unsigned src_pitch,
unsigned src_x,
unsigned src_y)
{
unsigned i;
@@ -210,10 +125,9 @@ i915_surface_data(struct pipe_context *pipe,
const void *src, unsigned src_pitch,
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
{
_mesa_copy_rect(pipe_surface_map(dst),
dst->cpp,
dst->pitch,
dstx, dsty, width, height, src, src_pitch, srcx, srcy);
copy_rect(pipe_surface_map(dst),
dst->cpp, dst->pitch,
dstx, dsty, width, height, src, src_pitch, srcx, srcy);
pipe_surface_unmap(dst);
}
@@ -233,7 +147,7 @@ i915_surface_copy(struct pipe_context *pipe,
assert( dst->cpp == src->cpp );
if (0) {
_mesa_copy_rect(pipe_surface_map(dst),
copy_rect(pipe_surface_map(dst),
dst->cpp,
dst->pitch,
dstx, dsty,
@@ -323,10 +237,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;
+25 -24
View File
@@ -156,38 +156,37 @@ static void upload_cc_unit( struct brw_context *brw )
memset(&cc, 0, sizeof(cc));
/* BRW_NEW_DEPTH_STENCIL */
if (brw->attribs.DepthStencil->stencil.front_enabled) {
cc.cc0.stencil_enable = brw->attribs.DepthStencil->stencil.front_enabled;
cc.cc0.stencil_func = brw_translate_compare_func(brw->attribs.DepthStencil->stencil.front_func);
cc.cc0.stencil_fail_op = brw_translate_stencil_op(brw->attribs.DepthStencil->stencil.front_fail_op);
if (brw->attribs.DepthStencil->stencil[0].enabled) {
cc.cc0.stencil_enable = brw->attribs.DepthStencil->stencil[0].enabled;
cc.cc0.stencil_func = brw_translate_compare_func(brw->attribs.DepthStencil->stencil[0].func);
cc.cc0.stencil_fail_op = brw_translate_stencil_op(brw->attribs.DepthStencil->stencil[0].fail_op);
cc.cc0.stencil_pass_depth_fail_op = brw_translate_stencil_op(
brw->attribs.DepthStencil->stencil.front_zfail_op);
brw->attribs.DepthStencil->stencil[0].zfail_op);
cc.cc0.stencil_pass_depth_pass_op = brw_translate_stencil_op(
brw->attribs.DepthStencil->stencil.front_zpass_op);
cc.cc1.stencil_ref = brw->attribs.DepthStencil->stencil.ref_value[0];
cc.cc1.stencil_write_mask = brw->attribs.DepthStencil->stencil.write_mask[0];
cc.cc1.stencil_test_mask = brw->attribs.DepthStencil->stencil.value_mask[0];
brw->attribs.DepthStencil->stencil[0].zpass_op);
cc.cc1.stencil_ref = brw->attribs.DepthStencil->stencil[0].ref_value;
cc.cc1.stencil_write_mask = brw->attribs.DepthStencil->stencil[0].write_mask;
cc.cc1.stencil_test_mask = brw->attribs.DepthStencil->stencil[0].value_mask;
if (brw->attribs.DepthStencil->stencil.back_enabled) {
cc.cc0.bf_stencil_enable = brw->attribs.DepthStencil->stencil.back_enabled;
if (brw->attribs.DepthStencil->stencil[1].enabled) {
cc.cc0.bf_stencil_enable = brw->attribs.DepthStencil->stencil[1].enabled;
cc.cc0.bf_stencil_func = brw_translate_compare_func(
brw->attribs.DepthStencil->stencil.back_func);
brw->attribs.DepthStencil->stencil[1].func);
cc.cc0.bf_stencil_fail_op = brw_translate_stencil_op(
brw->attribs.DepthStencil->stencil.back_fail_op);
brw->attribs.DepthStencil->stencil[1].fail_op);
cc.cc0.bf_stencil_pass_depth_fail_op = brw_translate_stencil_op(
brw->attribs.DepthStencil->stencil.back_zfail_op);
brw->attribs.DepthStencil->stencil[1].zfail_op);
cc.cc0.bf_stencil_pass_depth_pass_op = brw_translate_stencil_op(
brw->attribs.DepthStencil->stencil.back_zpass_op);
cc.cc1.bf_stencil_ref = brw->attribs.DepthStencil->stencil.ref_value[1];
cc.cc2.bf_stencil_write_mask = brw->attribs.DepthStencil->stencil.write_mask[1];
cc.cc2.bf_stencil_test_mask = brw->attribs.DepthStencil->stencil.value_mask[1];
brw->attribs.DepthStencil->stencil[1].zpass_op);
cc.cc1.bf_stencil_ref = brw->attribs.DepthStencil->stencil[1].ref_value;
cc.cc2.bf_stencil_write_mask = brw->attribs.DepthStencil->stencil[1].write_mask;
cc.cc2.bf_stencil_test_mask = brw->attribs.DepthStencil->stencil[1].value_mask;
}
/* Not really sure about this:
*/
if (brw->attribs.DepthStencil->stencil.write_mask[0] ||
(brw->attribs.DepthStencil->stencil.back_enabled &&
brw->attribs.DepthStencil->stencil.write_mask[1]))
if (brw->attribs.DepthStencil->stencil[0].write_mask ||
brw->attribs.DepthStencil->stencil[1].write_mask)
cc.cc0.stencil_write_enable = 1;
}
@@ -228,11 +227,13 @@ static void upload_cc_unit( struct brw_context *brw )
/* BRW_NEW_ALPHATEST
*/
if (brw->attribs.AlphaTest->enabled) {
if (brw->attribs.DepthStencil->alpha.enabled) {
cc.cc3.alpha_test = 1;
cc.cc3.alpha_test_func = brw_translate_compare_func(brw->attribs.AlphaTest->func);
cc.cc3.alpha_test_func =
brw_translate_compare_func(brw->attribs.DepthStencil->alpha.func);
UNCLAMPED_FLOAT_TO_UBYTE(cc.cc7.alpha_ref.ub[0], brw->attribs.AlphaTest->ref);
UNCLAMPED_FLOAT_TO_UBYTE(cc.cc7.alpha_ref.ub[0],
brw->attribs.DepthStencil->alpha.ref);
cc.cc3.alpha_test_format = BRW_ALPHATEST_FORMAT_UNORM8;
}
+1 -2
View File
@@ -479,9 +479,8 @@ struct brw_context
struct {
const struct pipe_alpha_test_state *AlphaTest;
const struct pipe_blend_state *Blend;
const struct pipe_depth_stencil_state *DepthStencil;
const struct pipe_depth_stencil_alpha_state *DepthStencil;
const struct pipe_poly_stipple *PolygonStipple;
const struct pipe_rasterizer_state *Raster;
const struct pipe_sampler_state *Samplers[PIPE_MAX_SAMPLERS];
-8
View File
@@ -156,14 +156,6 @@ void brw_upload_constant_buffer_state(struct brw_context *brw)
BRW_CACHED_BATCH_STRUCT(brw, &cbs);
}
const struct brw_tracked_state brw_constant_buffer_state = {
.dirty = {
.brw = BRW_NEW_URB_FENCE,
.cache = 0
},
.update = brw_upload_constant_buffer_state
};
static float fixed_plane[6][4] = {
{ 0, 0, -1, 1 },
+4 -2
View File
@@ -158,7 +158,8 @@ static boolean brw_try_draw_elements( struct pipe_context *pipe,
/* Upload index, vertex data:
*/
if (!brw_upload_indices( brw, index_buffer, index_size, start, count ))
if (index_buffer &&
!brw_upload_indices( brw, index_buffer, index_size, start, count ))
return FALSE;
if (!brw_upload_vertex_elements( brw ))
@@ -169,7 +170,8 @@ static boolean brw_try_draw_elements( struct pipe_context *pipe,
if (brw->state.dirty.brw)
brw_validate_state( brw );
if (brw_emit_prim(brw, TRUE, start, count))
if (!brw_emit_prim(brw, index_buffer != NULL,
start, count))
return FALSE;
return TRUE;
+7 -37
View File
@@ -116,9 +116,9 @@ static void brw_delete_sampler_state(struct pipe_context *pipe,
static void *
brw_create_depth_stencil_state(struct pipe_context *pipe,
const struct pipe_depth_stencil_state *depth_stencil)
const struct pipe_depth_stencil_alpha_state *depth_stencil)
{
DUP( pipe_depth_stencil_state, depth_stencil );
DUP( pipe_depth_stencil_alpha_state, depth_stencil );
}
static void brw_bind_depth_stencil_state(struct pipe_context *pipe,
@@ -126,7 +126,7 @@ static void brw_bind_depth_stencil_state(struct pipe_context *pipe,
{
struct brw_context *brw = brw_context(pipe);
brw->attribs.DepthStencil = (const struct pipe_depth_stencil_state *)depth_stencil;
brw->attribs.DepthStencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil;
brw->state.dirty.brw |= BRW_NEW_DEPTH_STENCIL;
}
@@ -137,32 +137,6 @@ static void brw_delete_depth_stencil_state(struct pipe_context *pipe,
free(depth_stencil);
}
/************************************************************************
* Alpha test
*/
static void *
brw_create_alpha_test_state(struct pipe_context *pipe,
const struct pipe_alpha_test_state *alpha_test)
{
DUP(pipe_alpha_test_state, alpha_test);
}
static void brw_bind_alpha_test_state(struct pipe_context *pipe,
void *alpha)
{
struct brw_context *brw = brw_context(pipe);
brw->attribs.AlphaTest = (const struct pipe_alpha_test_state*)alpha;
brw->state.dirty.brw |= BRW_NEW_ALPHA_TEST;
}
static void brw_delete_alpha_test_state(struct pipe_context *pipe,
void *alpha)
{
free(alpha);
}
/************************************************************************
* Scissor
*/
@@ -315,7 +289,7 @@ static void brw_set_vertex_element(struct pipe_context *pipe,
el.vep.ve0.valid = 1;
el.vep.ve0.vertex_buffer_index = element->vertex_buffer_index;
el.vep.ve1.dst_offset = element->dst_offset;
el.vep.ve1.dst_offset = index * 4;
el.vep.ve1.vfcomponent3 = BRW_VFCOMPONENT_STORE_SRC;
el.vep.ve1.vfcomponent2 = BRW_VFCOMPONENT_STORE_SRC;
el.vep.ve1.vfcomponent1 = BRW_VFCOMPONENT_STORE_SRC;
@@ -415,10 +389,6 @@ static void brw_delete_rasterizer_state(struct pipe_context *pipe,
void
brw_init_state_functions( struct brw_context *brw )
{
brw->pipe.create_alpha_test_state = brw_create_alpha_test_state;
brw->pipe.bind_alpha_test_state = brw_bind_alpha_test_state;
brw->pipe.delete_alpha_test_state = brw_delete_alpha_test_state;
brw->pipe.create_blend_state = brw_create_blend_state;
brw->pipe.bind_blend_state = brw_bind_blend_state;
brw->pipe.delete_blend_state = brw_delete_blend_state;
@@ -427,9 +397,9 @@ brw_init_state_functions( struct brw_context *brw )
brw->pipe.bind_sampler_state = brw_bind_sampler_state;
brw->pipe.delete_sampler_state = brw_delete_sampler_state;
brw->pipe.create_depth_stencil_state = brw_create_depth_stencil_state;
brw->pipe.bind_depth_stencil_state = brw_bind_depth_stencil_state;
brw->pipe.delete_depth_stencil_state = brw_delete_depth_stencil_state;
brw->pipe.create_depth_stencil_alpha_state = brw_create_depth_stencil_state;
brw->pipe.bind_depth_stencil_alpha_state = brw_bind_depth_stencil_state;
brw->pipe.delete_depth_stencil_alpha_state = brw_delete_depth_stencil_state;
brw->pipe.create_rasterizer_state = brw_create_rasterizer_state;
brw->pipe.bind_rasterizer_state = brw_bind_rasterizer_state;
+1 -2
View File
@@ -90,8 +90,7 @@ const struct brw_tracked_state *atoms[] =
&brw_psp_urb_cbs,
NULL, /* brw_constant_buffer */
&brw_constant_buffer
};
+21 -106
View File
@@ -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"
/*
@@ -157,21 +75,19 @@ brw_get_tex_surface(struct pipe_context *pipe,
return ps;
}
/*
* XXX Move this into core Mesa?
*/
static void
_mesa_copy_rect(ubyte * dst,
unsigned cpp,
unsigned dst_pitch,
unsigned dst_x,
unsigned dst_y,
unsigned width,
unsigned height,
const ubyte * src,
unsigned src_pitch,
unsigned src_x,
unsigned src_y)
copy_rect(ubyte * dst,
unsigned cpp,
unsigned dst_pitch,
unsigned dst_x,
unsigned dst_y,
unsigned width,
unsigned height,
const ubyte *src,
unsigned src_pitch,
unsigned src_x,
unsigned src_y)
{
unsigned i;
@@ -208,10 +124,9 @@ brw_surface_data(struct pipe_context *pipe,
const void *src, unsigned src_pitch,
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
{
_mesa_copy_rect(pipe_surface_map(dst) + dst->offset,
dst->cpp,
dst->pitch,
dstx, dsty, width, height, src, src_pitch, srcx, srcy);
copy_rect(pipe_surface_map(dst) + dst->offset,
dst->cpp, dst->pitch,
dstx, dsty, width, height, src, src_pitch, srcx, srcy);
pipe_surface_unmap(dst);
}
@@ -231,7 +146,7 @@ brw_surface_copy(struct pipe_context *pipe,
assert(dst->cpp == src->cpp);
if (0) {
_mesa_copy_rect(pipe_surface_map(dst) + dst->offset,
copy_rect(pipe_surface_map(dst) + dst->offset,
dst->cpp,
dst->pitch,
dstx, dsty,
@@ -321,10 +236,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;
-12
View File
@@ -183,15 +183,3 @@ void brw_upload_urb_fence(struct brw_context *brw)
BRW_BATCH_STRUCT(brw, &uf);
}
#if 0
const struct brw_tracked_state brw_urb_fence = {
.dirty = {
.mesa = 0,
.brw = BRW_NEW_URB_FENCE | BRW_NEW_PSP,
.cache = 0
},
.update = brw_upload_urb_fence
};
#endif
+5 -8
View File
@@ -93,15 +93,14 @@ static void brw_wm_populate_key( struct brw_context *brw,
/* Build the index for table lookup
*/
/* _NEW_COLOR */
/* BRW_NEW_DEPTH_STENCIL */
if (fp->UsesKill ||
brw->attribs.AlphaTest->enabled)
brw->attribs.DepthStencil->alpha.enabled)
lookup |= IZ_PS_KILL_ALPHATEST_BIT;
if (fp->ComputesDepth)
lookup |= IZ_PS_COMPUTES_DEPTH_BIT;
/* _NEW_DEPTH */
if (brw->attribs.DepthStencil->depth.enabled)
lookup |= IZ_DEPTH_TEST_ENABLE_BIT;
@@ -109,13 +108,11 @@ static void brw_wm_populate_key( struct brw_context *brw,
brw->attribs.DepthStencil->depth.writemask) /* ?? */
lookup |= IZ_DEPTH_WRITE_ENABLE_BIT;
/* _NEW_STENCIL */
if (brw->attribs.DepthStencil->stencil.front_enabled) {
if (brw->attribs.DepthStencil->stencil[0].enabled) {
lookup |= IZ_STENCIL_TEST_ENABLE_BIT;
if (brw->attribs.DepthStencil->stencil.write_mask[0] ||
(brw->attribs.DepthStencil->stencil.back_enabled &&
brw->attribs.DepthStencil->stencil.write_mask[1]))
if (brw->attribs.DepthStencil->stencil[0].write_mask ||
brw->attribs.DepthStencil->stencil[1].write_mask)
lookup |= IZ_STENCIL_WRITE_ENABLE_BIT;
}
+1 -1
View File
@@ -126,7 +126,7 @@ static struct brw_reg get_src_reg(struct brw_wm_compile *c,
/* Can't handle this, don't know if we need to:
*/
assert(src->SrcRegisterExtSwz.ExtDivide == 0);
assert(src->SrcRegisterExtSwz.ExtDivide == TGSI_EXTSWIZZLE_ONE);
/* Not handling indirect lookups yet:
*/
+1 -1
View File
@@ -122,7 +122,7 @@ static void upload_wm_unit(struct brw_context *brw )
/* BRW_NEW_ALPHA_TEST */
if (fp->UsesKill ||
brw->attribs.AlphaTest->enabled)
brw->attribs.DepthStencil->alpha.enabled)
wm.wm5.program_uses_killpixel = 1;
wm.wm5.enable_8_pix = 1;
@@ -237,6 +237,9 @@ static void upload_wm_surfaces(struct brw_context *brw )
for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
const struct brw_texture *texUnit = brw->attribs.Texture[i];
if (texUnit == NULL)
continue;
/* BRW_NEW_TEXTURE
*/
+4 -9
View File
@@ -102,11 +102,6 @@ struct pipe_context {
/*
* State functions
*/
void * (*create_alpha_test_state)(struct pipe_context *,
const struct pipe_alpha_test_state *);
void (*bind_alpha_test_state)(struct pipe_context *, void *);
void (*delete_alpha_test_state)(struct pipe_context *, void *);
void * (*create_blend_state)(struct pipe_context *,
const struct pipe_blend_state *);
void (*bind_blend_state)(struct pipe_context *, void *);
@@ -122,10 +117,10 @@ struct pipe_context {
void (*bind_rasterizer_state)(struct pipe_context *, void *);
void (*delete_rasterizer_state)(struct pipe_context *, void *);
void * (*create_depth_stencil_state)(struct pipe_context *,
const struct pipe_depth_stencil_state *);
void (*bind_depth_stencil_state)(struct pipe_context *, void *);
void (*delete_depth_stencil_state)(struct pipe_context *, void *);
void * (*create_depth_stencil_alpha_state)(struct pipe_context *,
const struct pipe_depth_stencil_alpha_state *);
void (*bind_depth_stencil_alpha_state)(struct pipe_context *, void *);
void (*delete_depth_stencil_alpha_state)(struct pipe_context *, void *);
void * (*create_fs_state)(struct pipe_context *,
const struct pipe_shader_state *);
+16 -20
View File
@@ -147,7 +147,7 @@ struct pipe_shader_state {
ubyte output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
};
struct pipe_depth_stencil_state
struct pipe_depth_stencil_alpha_state
{
struct {
unsigned enabled:1; /**< depth test enabled? */
@@ -156,27 +156,23 @@ struct pipe_depth_stencil_state
unsigned occlusion_count:1; /**< XXX move this elsewhere? */
} depth;
struct {
unsigned front_enabled:1;
unsigned front_func:3; /**< PIPE_FUNC_x */
unsigned front_fail_op:3; /**< PIPE_STENCIL_OP_x */
unsigned front_zpass_op:3; /**< PIPE_STENCIL_OP_x */
unsigned front_zfail_op:3; /**< PIPE_STENCIL_OP_x */
unsigned back_enabled:1;
unsigned back_func:3; /**< PIPE_FUNC_x */
unsigned back_fail_op:3; /**< PIPE_STENCIL_OP_x */
unsigned back_zpass_op:3; /**< PIPE_STENCIL_OP_x */
unsigned back_zfail_op:3; /**< PIPE_STENCIL_OP_x */
ubyte ref_value[2]; /**< [0] = front, [1] = back */
ubyte value_mask[2];
ubyte write_mask[2];
} stencil;
unsigned enabled:1;
unsigned func:3; /**< PIPE_FUNC_x */
unsigned fail_op:3; /**< PIPE_STENCIL_OP_x */
unsigned zpass_op:3; /**< PIPE_STENCIL_OP_x */
unsigned zfail_op:3; /**< PIPE_STENCIL_OP_x */
ubyte ref_value;
ubyte value_mask;
ubyte write_mask;
} stencil[2]; /**< [0] = front, [1] = back */
struct {
unsigned enabled:1;
unsigned func:3; /**< PIPE_FUNC_x */
float ref; /**< reference value */
} alpha;
};
struct pipe_alpha_test_state {
unsigned enabled:1;
unsigned func:3; /**< PIPE_FUNC_x */
float ref; /**< reference value */
};
struct pipe_blend_state {
unsigned blend_enable:1;
-1
View File
@@ -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 \
+3 -7
View File
@@ -240,10 +240,6 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
softpipe->pipe.get_paramf = softpipe_get_paramf;
/* state setters */
softpipe->pipe.create_alpha_test_state = softpipe_create_alpha_test_state;
softpipe->pipe.bind_alpha_test_state = softpipe_bind_alpha_test_state;
softpipe->pipe.delete_alpha_test_state = softpipe_delete_alpha_test_state;
softpipe->pipe.create_blend_state = softpipe_create_blend_state;
softpipe->pipe.bind_blend_state = softpipe_bind_blend_state;
softpipe->pipe.delete_blend_state = softpipe_delete_blend_state;
@@ -252,9 +248,9 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
softpipe->pipe.bind_sampler_state = softpipe_bind_sampler_state;
softpipe->pipe.delete_sampler_state = softpipe_delete_sampler_state;
softpipe->pipe.create_depth_stencil_state = softpipe_create_depth_stencil_state;
softpipe->pipe.bind_depth_stencil_state = softpipe_bind_depth_stencil_state;
softpipe->pipe.delete_depth_stencil_state = softpipe_delete_depth_stencil_state;
softpipe->pipe.create_depth_stencil_alpha_state = softpipe_create_depth_stencil_state;
softpipe->pipe.bind_depth_stencil_alpha_state = softpipe_bind_depth_stencil_state;
softpipe->pipe.delete_depth_stencil_alpha_state = softpipe_delete_depth_stencil_state;
softpipe->pipe.create_rasterizer_state = softpipe_create_rasterizer_state;
softpipe->pipe.bind_rasterizer_state = softpipe_bind_rasterizer_state;
+4 -5
View File
@@ -53,13 +53,13 @@ struct softpipe_tile_cache;
#define SP_NEW_SCISSOR 0x20
#define SP_NEW_STIPPLE 0x40
#define SP_NEW_FRAMEBUFFER 0x80
#define SP_NEW_ALPHA_TEST 0x100
#define SP_NEW_DEPTH_STENCIL 0x200
#define SP_NEW_DEPTH_STENCIL_ALPHA 0x100
#define SP_NEW_CONSTANTS 0x200
#define SP_NEW_SAMPLER 0x400
#define SP_NEW_TEXTURE 0x800
#define SP_NEW_VERTEX 0x1000
#define SP_NEW_VS 0x2000
#define SP_NEW_CONSTANTS 0x4000
#define SP_NEW_QUERY 0x4000
struct sp_vertex_shader_state {
struct pipe_shader_state *state;
@@ -73,10 +73,9 @@ struct softpipe_context {
/* The most recent drawing state as set by the driver:
*/
const struct pipe_alpha_test_state *alpha_test;
const struct pipe_blend_state *blend;
const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
const struct pipe_depth_stencil_state *depth_stencil;
const struct pipe_depth_stencil_alpha_state *depth_stencil;
const struct pipe_rasterizer_state *rasterizer;
const struct sp_fragment_shader_state *fs;
const struct sp_vertex_shader_state *vs;
+4 -4
View File
@@ -43,8 +43,8 @@ static void
sp_build_depth_stencil(
struct softpipe_context *sp )
{
if (sp->depth_stencil->stencil.front_enabled ||
sp->depth_stencil->stencil.back_enabled) {
if (sp->depth_stencil->stencil[0].enabled ||
sp->depth_stencil->stencil[1].enabled) {
sp_push_quad_first( sp, sp->quad.stencil_test );
}
else if (sp->depth_stencil->depth.enabled &&
@@ -59,7 +59,7 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
boolean early_depth_test =
sp->depth_stencil->depth.enabled &&
sp->framebuffer.zbuf &&
!sp->alpha_test->enabled &&
!sp->depth_stencil->alpha.enabled &&
sp->fs->shader.output_semantic_name[0] != TGSI_SEMANTIC_POSITION;
/* build up the pipeline in reverse order... */
@@ -98,7 +98,7 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
sp_build_depth_stencil( sp );
}
if (sp->alpha_test->enabled) {
if (sp->depth_stencil->alpha.enabled) {
sp_push_quad_first( sp, sp->quad.alpha_test );
}
+2 -2
View File
@@ -14,11 +14,11 @@ static void
alpha_test_quad(struct quad_stage *qs, struct quad_header *quad)
{
struct softpipe_context *softpipe = qs->softpipe;
const float ref = softpipe->alpha_test->ref;
const float ref = softpipe->depth_stencil->alpha.ref;
unsigned passMask = 0x0, j;
const float *aaaa = quad->outputs.color[3];
switch (softpipe->alpha_test->func) {
switch (softpipe->depth_stencil->alpha.func) {
case PIPE_FUNC_NEVER:
quad->mask = 0x0;
break;
+7 -18
View File
@@ -211,24 +211,13 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
/* choose front or back face function, operator, etc */
/* XXX we could do these initializations once per primitive */
if (softpipe->depth_stencil->stencil.back_enabled && quad->facing) {
func = softpipe->depth_stencil->stencil.back_func;
failOp = softpipe->depth_stencil->stencil.back_fail_op;
zFailOp = softpipe->depth_stencil->stencil.back_zfail_op;
zPassOp = softpipe->depth_stencil->stencil.back_zpass_op;
ref = softpipe->depth_stencil->stencil.ref_value[1];
wrtMask = softpipe->depth_stencil->stencil.write_mask[1];
valMask = softpipe->depth_stencil->stencil.value_mask[1];
}
else {
func = softpipe->depth_stencil->stencil.front_func;
failOp = softpipe->depth_stencil->stencil.front_fail_op;
zFailOp = softpipe->depth_stencil->stencil.front_zfail_op;
zPassOp = softpipe->depth_stencil->stencil.front_zpass_op;
ref = softpipe->depth_stencil->stencil.ref_value[0];
wrtMask = softpipe->depth_stencil->stencil.write_mask[0];
valMask = softpipe->depth_stencil->stencil.value_mask[0];
}
func = softpipe->depth_stencil->stencil[quad->facing].func;
failOp = softpipe->depth_stencil->stencil[quad->facing].fail_op;
zFailOp = softpipe->depth_stencil->stencil[quad->facing].zfail_op;
zPassOp = softpipe->depth_stencil->stencil[quad->facing].zpass_op;
ref = softpipe->depth_stencil->stencil[quad->facing].ref_value;
wrtMask = softpipe->depth_stencil->stencil[quad->facing].write_mask;
valMask = softpipe->depth_stencil->stencil[quad->facing].value_mask;
assert(ps); /* shouldn't get here if there's no stencil buffer */
+1 -8
View File
@@ -52,13 +52,6 @@ struct sp_fragment_shader_state {
#endif
};
void *
softpipe_create_alpha_test_state(struct pipe_context *,
const struct pipe_alpha_test_state *);
void
softpipe_bind_alpha_test_state(struct pipe_context *, void *);
void
softpipe_delete_alpha_test_state(struct pipe_context *, void *);
void *
softpipe_create_blend_state(struct pipe_context *,
@@ -76,7 +69,7 @@ void softpipe_delete_sampler_state(struct pipe_context *, void *);
void *
softpipe_create_depth_stencil_state(struct pipe_context *,
const struct pipe_depth_stencil_state *);
const struct pipe_depth_stencil_alpha_state *);
void softpipe_bind_depth_stencil_state(struct pipe_context *, void *);
void softpipe_delete_depth_stencil_state(struct pipe_context *, void *);
+6 -32
View File
@@ -73,40 +73,14 @@ void softpipe_set_blend_color( struct pipe_context *pipe,
* into one file.
*/
void *
softpipe_create_alpha_test_state(struct pipe_context *pipe,
const struct pipe_alpha_test_state *alpha)
{
struct pipe_alpha_test_state *state = MALLOC( sizeof(struct pipe_alpha_test_state) );
memcpy(state, alpha, sizeof(struct pipe_alpha_test_state));
return state;
}
void
softpipe_bind_alpha_test_state(struct pipe_context *pipe,
void *alpha)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
softpipe->alpha_test = (const struct pipe_alpha_test_state *)alpha;
softpipe->dirty |= SP_NEW_ALPHA_TEST;
}
void
softpipe_delete_alpha_test_state(struct pipe_context *pipe,
void *alpha)
{
FREE( alpha );
}
void *
softpipe_create_depth_stencil_state(struct pipe_context *pipe,
const struct pipe_depth_stencil_state *depth_stencil)
const struct pipe_depth_stencil_alpha_state *depth_stencil)
{
struct pipe_depth_stencil_state *state =
MALLOC( sizeof(struct pipe_depth_stencil_state) );
memcpy(state, depth_stencil, sizeof(struct pipe_depth_stencil_state));
struct pipe_depth_stencil_alpha_state *state =
MALLOC( sizeof(struct pipe_depth_stencil_alpha_state) );
memcpy(state, depth_stencil, sizeof(struct pipe_depth_stencil_alpha_state));
return state;
}
@@ -116,9 +90,9 @@ softpipe_bind_depth_stencil_state(struct pipe_context *pipe,
{
struct softpipe_context *softpipe = softpipe_context(pipe);
softpipe->depth_stencil = (const struct pipe_depth_stencil_state *)depth_stencil;
softpipe->depth_stencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil;
softpipe->dirty |= SP_NEW_DEPTH_STENCIL;
softpipe->dirty |= SP_NEW_DEPTH_STENCIL_ALPHA;
}
void
+4 -4
View File
@@ -201,16 +201,16 @@ void softpipe_update_derived( struct softpipe_context *softpipe )
calculate_vertex_layout( softpipe );
if (softpipe->dirty & (SP_NEW_SCISSOR |
SP_NEW_DEPTH_STENCIL |
SP_NEW_DEPTH_STENCIL_ALPHA |
SP_NEW_FRAMEBUFFER))
compute_cliprect(softpipe);
if (softpipe->dirty & (SP_NEW_BLEND |
SP_NEW_DEPTH_STENCIL |
SP_NEW_ALPHA_TEST |
SP_NEW_DEPTH_STENCIL_ALPHA |
SP_NEW_FRAMEBUFFER |
SP_NEW_RASTERIZER |
SP_NEW_FS))
SP_NEW_FS |
SP_NEW_QUERY))
sp_build_quad_pipeline(softpipe);
softpipe->dirty = 0;
+9 -86
View File
@@ -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;
+12 -11
View File
@@ -58,6 +58,8 @@ struct softpipe_tile_cache
struct pipe_surface *tex_surf;
int tex_face, tex_level, tex_z;
struct softpipe_cached_tile tile; /**< scratch tile for clears */
};
@@ -234,13 +236,11 @@ clear_tile(struct softpipe_cached_tile *tile,
{
uint i, j;
switch (format) {
case PIPE_FORMAT_U_S8:
/* 8 bpp */
switch (pf_get_size(format)) {
case 1:
memset(tile->data.any, 0, TILE_SIZE * TILE_SIZE);
break;
case PIPE_FORMAT_Z16_UNORM:
/* 16 bpp */
case 2:
if (clear_value == 0) {
memset(tile->data.any, 0, 2 * TILE_SIZE * TILE_SIZE);
}
@@ -252,8 +252,7 @@ clear_tile(struct softpipe_cached_tile *tile,
}
}
break;
default:
/* 32 bpp */
case 4:
if (clear_value == 0) {
memset(tile->data.any, 0, 4 * TILE_SIZE * TILE_SIZE);
}
@@ -264,6 +263,9 @@ clear_tile(struct softpipe_cached_tile *tile,
}
}
}
break;
default:
assert(0);
}
}
@@ -279,11 +281,10 @@ sp_tile_cache_flush_clear(struct pipe_context *pipe,
const uint w = tc->surface->width;
const uint h = tc->surface->height;
uint x, y;
struct softpipe_cached_tile tile;
uint numCleared = 0;
/* clear one tile to the clear value */
clear_tile(&tile, ps->format, tc->clear_val);
/* clear the scratch tile to the clear value */
clear_tile(&tc->tile, ps->format, tc->clear_val);
/* push the tile to all positions marked as clear */
for (y = 0; y < h; y += TILE_SIZE) {
@@ -291,7 +292,7 @@ sp_tile_cache_flush_clear(struct pipe_context *pipe,
if (is_clear_flag_set(tc->clear_flags, x, y)) {
pipe->put_tile(pipe, ps,
x, y, TILE_SIZE, TILE_SIZE,
tile.data.color32, 0/*STRIDE*/);
tc->tile.data.color32, 0/*STRIDE*/);
/* do this? */
clear_clear_flag(tc->clear_flags, x, y);
+834
View File
@@ -0,0 +1,834 @@
/**************************************************************************
*
* 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.
*
**************************************************************************/
/**
* RGBA/float tile get/put functions.
* Usable both by drivers and state trackers.
* Surfaces should already be in a mapped state.
*/
#include "pipe/p_defines.h"
#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "p_tile.h"
/**
* Move raw block of pixels from surface to user memory.
* This should be usable by any hw driver that has mappable surfaces.
*/
void
pipe_get_tile_raw(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;
}
if (pipe_clip_tile(x, y, &w, &h, ps))
return;
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.
* This should be usable by any hw driver that has mappable surfaces.
*/
void
pipe_put_tile_raw(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;
}
if (pipe_clip_tile(x, y, &w, &h, ps))
return;
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;
}
}
/** Convert short in [-32768,32767] to GLfloat in [-1.0,1.0] */
#define SHORT_TO_FLOAT(S) ((2.0F * (S) + 1.0F) * (1.0F/65535.0F))
#define UNCLAMPED_FLOAT_TO_SHORT(us, f) \
us = ( (short) ( CLAMP((f), -1.0, 1.0) * 32767.0F) )
/*** PIPE_FORMAT_A8R8G8B8_UNORM ***/
static void
a8r8g8b8_get_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
float *p)
{
const unsigned *src
= ((const unsigned *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
assert(ps->format == PIPE_FORMAT_A8R8G8B8_UNORM);
if (pipe_clip_tile(x, y, &w, &h, ps))
return;
for (i = 0; i < h; i++) {
float *pRow = p;
for (j = 0; j < w; j++) {
const unsigned pixel = src[j];
pRow[0] = UBYTE_TO_FLOAT((pixel >> 16) & 0xff);
pRow[1] = UBYTE_TO_FLOAT((pixel >> 8) & 0xff);
pRow[2] = UBYTE_TO_FLOAT((pixel >> 0) & 0xff);
pRow[3] = UBYTE_TO_FLOAT((pixel >> 24) & 0xff);
pRow += 4;
}
src += ps->pitch;
p += w0 * 4;
}
}
static void
a8r8g8b8_put_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
const float *p)
{
unsigned *dst
= ((unsigned *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
assert(ps->format == PIPE_FORMAT_A8R8G8B8_UNORM);
if (pipe_clip_tile(x, y, &w, &h, ps))
return;
for (i = 0; i < h; i++) {
const float *pRow = p;
for (j = 0; j < w; j++) {
unsigned r, g, b, a;
UNCLAMPED_FLOAT_TO_UBYTE(r, pRow[0]);
UNCLAMPED_FLOAT_TO_UBYTE(g, pRow[1]);
UNCLAMPED_FLOAT_TO_UBYTE(b, pRow[2]);
UNCLAMPED_FLOAT_TO_UBYTE(a, pRow[3]);
dst[j] = (a << 24) | (r << 16) | (g << 8) | b;
pRow += 4;
}
dst += ps->pitch;
p += w0 * 4;
}
}
/*** PIPE_FORMAT_B8G8R8A8_UNORM ***/
static void
b8g8r8a8_get_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
float *p)
{
const unsigned *src
= ((const unsigned *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
assert(ps->format == PIPE_FORMAT_B8G8R8A8_UNORM);
if (pipe_clip_tile(x, y, &w, &h, ps))
return;
for (i = 0; i < h; i++) {
float *pRow = p;
for (j = 0; j < w; j++) {
const unsigned pixel = src[j];
pRow[0] = UBYTE_TO_FLOAT((pixel >> 8) & 0xff);
pRow[1] = UBYTE_TO_FLOAT((pixel >> 16) & 0xff);
pRow[2] = UBYTE_TO_FLOAT((pixel >> 24) & 0xff);
pRow[3] = UBYTE_TO_FLOAT((pixel >> 0) & 0xff);
pRow += 4;
}
src += ps->pitch;
p += w0 * 4;
}
}
static void
b8g8r8a8_put_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
const float *p)
{
unsigned *dst
= ((unsigned *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
assert(ps->format == PIPE_FORMAT_B8G8R8A8_UNORM);
if (pipe_clip_tile(x, y, &w, &h, ps))
return;
for (i = 0; i < h; i++) {
const float *pRow = p;
for (j = 0; j < w; j++) {
unsigned r, g, b, a;
UNCLAMPED_FLOAT_TO_UBYTE(r, pRow[0]);
UNCLAMPED_FLOAT_TO_UBYTE(g, pRow[1]);
UNCLAMPED_FLOAT_TO_UBYTE(b, pRow[2]);
UNCLAMPED_FLOAT_TO_UBYTE(a, pRow[3]);
dst[j] = (b << 24) | (g << 16) | (r << 8) | a;
pRow += 4;
}
dst += ps->pitch;
p += w0 * 4;
}
}
/*** PIPE_FORMAT_A1R5G5B5_UNORM ***/
static void
a1r5g5b5_get_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
float *p)
{
const ushort *src
= ((const ushort *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
assert(ps->format == PIPE_FORMAT_A1R5G5B5_UNORM);
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
const ushort pixel = src[j];
p[0] = ((pixel >> 10) & 0x1f) * (1.0f / 31.0f);
p[1] = ((pixel >> 5) & 0x1f) * (1.0f / 31.0f);
p[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f);
p[3] = ((pixel >> 15) ) * 1.0f;
p += 4;
}
src += ps->pitch;
}
}
/*** PIPE_FORMAT_A4R4G4B4_UNORM ***/
static void
a4r4g4b4_get_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
float *p)
{
const ushort *src
= ((const ushort *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
assert(ps->format == PIPE_FORMAT_A4R4G4B4_UNORM);
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
const ushort pixel = src[j];
p[0] = ((pixel >> 8) & 0xf) * (1.0f / 15.0f);
p[1] = ((pixel >> 4) & 0xf) * (1.0f / 15.0f);
p[2] = ((pixel ) & 0xf) * (1.0f / 15.0f);
p[3] = ((pixel >> 12) ) * (1.0f / 15.0f);
p += 4;
}
src += ps->pitch;
}
}
/*** PIPE_FORMAT_R5G6B5_UNORM ***/
static void
r5g6b5_get_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
float *p)
{
const ushort *src
= ((const ushort *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
assert(ps->format == PIPE_FORMAT_R5G6B5_UNORM);
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
const ushort pixel = src[j];
p[0] = ((pixel >> 11) & 0x1f) * (1.0f / 31.0f);
p[1] = ((pixel >> 5) & 0x3f) * (1.0f / 63.0f);
p[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f);
p[3] = 1.0f;
p += 4;
}
src += ps->pitch;
}
}
static void
r5g5b5_put_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
const float *p)
{
ushort *dst
= ((ushort *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
assert(ps->format == PIPE_FORMAT_R5G6B5_UNORM);
if (pipe_clip_tile(x, y, &w, &h, ps))
return;
for (i = 0; i < h; i++) {
const float *pRow = p;
for (j = 0; j < w; j++) {
uint r = (uint) (CLAMP(pRow[0], 0.0, 1.0) * 31.0);
uint g = (uint) (CLAMP(pRow[1], 0.0, 1.0) * 63.0);
uint b = (uint) (CLAMP(pRow[2], 0.0, 1.0) * 31.0);
dst[j] = (r << 11) | (g << 5) | (b);
pRow += 4;
}
dst += ps->pitch;
p += w0 * 4;
}
}
/*** PIPE_FORMAT_Z16_UNORM ***/
/**
* Return each Z value as four floats in [0,1].
*/
static void
z16_get_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
float *p)
{
const ushort *src
= ((const ushort *) (ps->map))
+ y * ps->pitch + x;
const float scale = 1.0f / 65535.0f;
unsigned i, j;
unsigned w0 = w;
assert(ps->format == PIPE_FORMAT_Z16_UNORM);
if (pipe_clip_tile(x, y, &w, &h, ps))
return;
for (i = 0; i < h; i++) {
float *pRow = p;
for (j = 0; j < w; j++) {
pRow[j * 4 + 0] =
pRow[j * 4 + 1] =
pRow[j * 4 + 2] =
pRow[j * 4 + 3] = src[j] * scale;
}
src += ps->pitch;
p += 4 * w0;
}
}
/*** PIPE_FORMAT_U_L8 ***/
static void
l8_get_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
float *p)
{
const ubyte *src
= ((const ubyte *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
assert(ps->format == PIPE_FORMAT_U_L8);
if (pipe_clip_tile(x, y, &w, &h, ps))
return;
for (i = 0; i < h; i++) {
float *pRow = p;
for (j = 0; j < w; j++) {
pRow[0] =
pRow[1] =
pRow[2] = UBYTE_TO_FLOAT(src[j]);
pRow[3] = 1.0;
pRow += 4;
}
src += ps->pitch;
p += w0 * 4;
}
}
/*** PIPE_FORMAT_U_A8 ***/
static void
a8_get_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
float *p)
{
const ubyte *src
= ((const ubyte *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
assert(ps->format == PIPE_FORMAT_U_A8);
if (pipe_clip_tile(x, y, &w, &h, ps))
return;
for (i = 0; i < h; i++) {
float *pRow = p;
for (j = 0; j < w; j++) {
pRow[0] =
pRow[1] =
pRow[2] = 0.0;
pRow[3] = UBYTE_TO_FLOAT(src[j]);
pRow += 4;
}
src += ps->pitch;
p += w0 * 4;
}
}
/*** PIPE_FORMAT_R16G16B16A16_SNORM ***/
static void
r16g16b16a16_get_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
float *p)
{
const short *src
= ((const short *) (ps->map))
+ (y * ps->pitch + x) * 4;
unsigned i, j;
unsigned w0 = w;
assert(ps->format == PIPE_FORMAT_R16G16B16A16_SNORM);
if (pipe_clip_tile(x, y, &w, &h, ps))
return;
for (i = 0; i < h; i++) {
float *pRow = p;
const short *pixel = src;
for (j = 0; j < w; j++) {
pRow[0] = SHORT_TO_FLOAT(pixel[0]);
pRow[1] = SHORT_TO_FLOAT(pixel[1]);
pRow[2] = SHORT_TO_FLOAT(pixel[2]);
pRow[3] = SHORT_TO_FLOAT(pixel[3]);
pRow += 4;
pixel += 4;
}
src += ps->pitch * 4;
p += w0 * 4;
}
}
static void
r16g16b16a16_put_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
const float *p)
{
short *dst
= ((short *) (ps->map))
+ (y * ps->pitch + x) * 4;
unsigned i, j;
unsigned w0 = w;
assert(ps->format == PIPE_FORMAT_R16G16B16A16_SNORM);
if (pipe_clip_tile(x, y, &w, &h, ps))
return;
for (i = 0; i < h; i++) {
const float *pRow = p;
for (j = 0; j < w; j++) {
short r, g, b, a;
UNCLAMPED_FLOAT_TO_SHORT(r, pRow[0]);
UNCLAMPED_FLOAT_TO_SHORT(g, pRow[1]);
UNCLAMPED_FLOAT_TO_SHORT(b, pRow[2]);
UNCLAMPED_FLOAT_TO_SHORT(a, pRow[3]);
dst[j*4+0] = r;
dst[j*4+1] = g;
dst[j*4+2] = b;
dst[j*4+3] = a;
pRow += 4;
}
dst += ps->pitch * 4;
p += w0 * 4;
}
}
/*** PIPE_FORMAT_U_I8 ***/
static void
i8_get_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
float *p)
{
const ubyte *src
= ((const ubyte *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
assert(ps->format == PIPE_FORMAT_U_I8);
if (pipe_clip_tile(x, y, &w, &h, ps))
return;
for (i = 0; i < h; i++) {
float *pRow = p;
for (j = 0; j < w; j++) {
pRow[0] =
pRow[1] =
pRow[2] =
pRow[3] = UBYTE_TO_FLOAT(src[j]);
pRow += 4;
}
src += ps->pitch;
p += w0 * 4;
}
}
/*** PIPE_FORMAT_U_A8_L8 ***/
static void
a8_l8_get_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
float *p)
{
const ushort *src
= ((const ushort *) (ps->map))
+ y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
assert(ps->format == PIPE_FORMAT_U_A8_L8);
if (pipe_clip_tile(x, y, &w, &h, ps))
return;
for (i = 0; i < h; i++) {
float *pRow = p;
for (j = 0; j < w; j++) {
const ushort p = src[j];
pRow[0] =
pRow[1] =
pRow[2] = UBYTE_TO_FLOAT(p & 0xff);
pRow[3] = UBYTE_TO_FLOAT(p >> 8);
pRow += 4;
}
src += ps->pitch;
p += w0 * 4;
}
}
/*** PIPE_FORMAT_Z32_UNORM ***/
/**
* Return each Z value as four floats in [0,1].
*/
static void
z32_get_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
float *p)
{
const uint *src
= ((const uint *) (ps->map))
+ y * ps->pitch + x;
const double scale = 1.0 / (double) 0xffffffff;
unsigned i, j;
unsigned w0 = w;
assert(ps->format == PIPE_FORMAT_Z16_UNORM);
if (pipe_clip_tile(x, y, &w, &h, ps))
return;
for (i = 0; i < h; i++) {
float *pRow = p;
for (j = 0; j < w; j++) {
pRow[j * 4 + 0] =
pRow[j * 4 + 1] =
pRow[j * 4 + 2] =
pRow[j * 4 + 3] = (float) (scale * src[j]);
}
src += ps->pitch;
p += 4 * w0;
}
}
/*** PIPE_FORMAT_S8Z24_UNORM ***/
/**
* Return Z component as four float in [0,1]. Stencil part ignored.
*/
static void
s8z24_get_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
float *p)
{
const uint *src
= ((const uint *) (ps->map))
+ y * ps->pitch + x;
const double scale = 1.0 / ((1 << 24) - 1);
unsigned i, j;
unsigned w0 = w;
assert(ps->format == PIPE_FORMAT_S8Z24_UNORM);
if (pipe_clip_tile(x, y, &w, &h, ps))
return;
for (i = 0; i < h; i++) {
float *pRow = p;
for (j = 0; j < w; j++) {
pRow[j * 4 + 0] =
pRow[j * 4 + 1] =
pRow[j * 4 + 2] =
pRow[j * 4 + 3] = (float) (scale * (src[j] & 0xffffff));
}
src += ps->pitch;
p += 4 * w0;
}
}
/*** PIPE_FORMAT_Z24S8_UNORM ***/
/**
* Return Z component as four float in [0,1]. Stencil part ignored.
*/
static void
z24s8_get_tile_rgba(struct pipe_surface *ps,
unsigned x, unsigned y, unsigned w, unsigned h,
float *p)
{
const uint *src
= ((const uint *) (ps->map))
+ y * ps->pitch + x;
const double scale = 1.0 / ((1 << 24) - 1);
unsigned i, j;
unsigned w0 = w;
assert(ps->format == PIPE_FORMAT_Z24S8_UNORM);
if (pipe_clip_tile(x, y, &w, &h, ps))
return;
for (i = 0; i < h; i++) {
float *pRow = p;
for (j = 0; j < w; j++) {
pRow[j * 4 + 0] =
pRow[j * 4 + 1] =
pRow[j * 4 + 2] =
pRow[j * 4 + 3] = (float) (scale * (src[j] >> 8));
}
src += ps->pitch;
p += 4 * w0;
}
}
void
pipe_get_tile_rgba(struct pipe_context *pipe,
struct pipe_surface *ps,
uint x, uint y, uint w, uint h,
float *p)
{
switch (ps->format) {
case PIPE_FORMAT_A8R8G8B8_UNORM:
a8r8g8b8_get_tile_rgba(ps, x, y, w, h, p);
break;
case PIPE_FORMAT_B8G8R8A8_UNORM:
b8g8r8a8_get_tile_rgba(ps, x, y, w, h, p);
break;
case PIPE_FORMAT_A1R5G5B5_UNORM:
a1r5g5b5_get_tile_rgba(ps, x, y, w, h, p);
break;
case PIPE_FORMAT_A4R4G4B4_UNORM:
a4r4g4b4_get_tile_rgba(ps, x, y, w, h, p);
break;
case PIPE_FORMAT_R5G6B5_UNORM:
r5g6b5_get_tile_rgba(ps, x, y, w, h, p);
break;
case PIPE_FORMAT_U_L8:
l8_get_tile_rgba(ps, x, y, w, h, p);
break;
case PIPE_FORMAT_U_A8:
a8_get_tile_rgba(ps, x, y, w, h, p);
break;
case PIPE_FORMAT_U_I8:
i8_get_tile_rgba(ps, x, y, w, h, p);
break;
case PIPE_FORMAT_U_A8_L8:
a8_l8_get_tile_rgba(ps, x, y, w, h, p);
break;
case PIPE_FORMAT_R16G16B16A16_SNORM:
r16g16b16a16_get_tile_rgba(ps, x, y, w, h, p);
break;
case PIPE_FORMAT_Z16_UNORM:
z16_get_tile_rgba(ps, x, y, w, h, p);
break;
case PIPE_FORMAT_Z32_UNORM:
z32_get_tile_rgba(ps, x, y, w, h, p);
break;
case PIPE_FORMAT_S8Z24_UNORM:
s8z24_get_tile_rgba(ps, x, y, w, h, p);
break;
case PIPE_FORMAT_Z24S8_UNORM:
z24s8_get_tile_rgba(ps, x, y, w, h, p);
break;
default:
assert(0);
}
}
void
pipe_put_tile_rgba(struct pipe_context *pipe,
struct pipe_surface *ps,
uint x, uint y, uint w, uint h,
const float *p)
{
switch (ps->format) {
case PIPE_FORMAT_A8R8G8B8_UNORM:
a8r8g8b8_put_tile_rgba(ps, x, y, w, h, p);
break;
case PIPE_FORMAT_B8G8R8A8_UNORM:
b8g8r8a8_put_tile_rgba(ps, x, y, w, h, p);
break;
case PIPE_FORMAT_A1R5G5B5_UNORM:
/*a1r5g5b5_put_tile_rgba(ps, x, y, w, h, p);*/
break;
case PIPE_FORMAT_R5G6B5_UNORM:
r5g5b5_put_tile_rgba(ps, x, y, w, h, p);
break;
case PIPE_FORMAT_R8G8B8A8_UNORM:
break;
case PIPE_FORMAT_U_L8:
/*l8_put_tile_rgba(ps, x, y, w, h, p);*/
break;
case PIPE_FORMAT_U_A8:
/*a8_put_tile_rgba(ps, x, y, w, h, p);*/
break;
case PIPE_FORMAT_U_I8:
/*i8_put_tile_rgba(ps, x, y, w, h, p);*/
break;
case PIPE_FORMAT_U_A8_L8:
/*a8_l8_put_tile_rgba(ps, x, y, w, h, p);*/
break;
case PIPE_FORMAT_R16G16B16A16_SNORM:
r16g16b16a16_put_tile_rgba(ps, x, y, w, h, p);
break;
case PIPE_FORMAT_Z16_UNORM:
/*z16_put_tile_rgba(ps, x, y, w, h, p);*/
break;
case PIPE_FORMAT_Z32_UNORM:
/*z32_put_tile_rgba(ps, x, y, w, h, p);*/
break;
case PIPE_FORMAT_S8Z24_UNORM:
/*s8z24_put_tile_rgba(ps, x, y, w, h, p);*/
break;
case PIPE_FORMAT_Z24S8_UNORM:
/*z24s8_put_tile_rgba(ps, x, y, w, h, p);*/
break;
default:
assert(0);
}
}
+81
View File
@@ -0,0 +1,81 @@
/**************************************************************************
*
* 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 P_TILE_H
#define P_TILE_H
#include "pipe/p_compiler.h"
struct pipe_context;
struct pipe_surface;
/**
* Clip tile against surface dims.
* \return TRUE if tile is totally clipped, FALSE otherwise
*/
static INLINE boolean
pipe_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_surface *ps)
{
if (x >= ps->width)
return TRUE;
if (y >= ps->height)
return TRUE;
if (x + *w > ps->width)
*w = ps->width - x;
if (y + *h > ps->height)
*h = ps->height - y;
return FALSE;
}
extern void
pipe_get_tile_raw(struct pipe_context *pipe,
struct pipe_surface *ps,
uint x, uint y, uint w, uint h,
void *p, int dst_stride);
extern void
pipe_put_tile_raw(struct pipe_context *pipe,
struct pipe_surface *ps,
uint x, uint y, uint w, uint h,
const void *p, int src_stride);
extern void
pipe_get_tile_rgba(struct pipe_context *pipe,
struct pipe_surface *ps,
uint x, uint y, uint w, uint h,
float *p);
extern void
pipe_put_tile_rgba(struct pipe_context *pipe,
struct pipe_surface *ps,
uint x, uint y, uint w, uint h,
const float *p);
#endif
+4 -1
View File
@@ -196,9 +196,11 @@ 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 \
state_tracker/st_atom_blend.c \
state_tracker/st_atom_clip.c \
state_tracker/st_atom_constbuf.c \
@@ -383,6 +385,7 @@ SOLO_SOURCES = \
$(DRAW_SOURCES) \
$(TGSIEXEC_SOURCES) \
$(TGSIUTIL_SOURCES) \
$(PIPEUTIL_SOURCES) \
$(STATECACHE_SOURCES) \
$(STATETRACKER_SOURCES) \
$(TNL_SOURCES) \
+1 -2
View File
@@ -45,7 +45,7 @@
static const struct st_tracked_state *atoms[] =
{
&st_update_framebuffer,
&st_update_depth_stencil,
&st_update_depth_stencil_alpha,
&st_update_clip,
&st_update_shader,
@@ -59,7 +59,6 @@ static const struct st_tracked_state *atoms[] =
&st_update_texture,
&st_update_vs_constants,
&st_update_fs_constants,
&st_update_alpha_test,
&st_update_pixel_transfer
};
+1 -2
View File
@@ -46,7 +46,7 @@ void st_validate_state( struct st_context *st );
const struct st_tracked_state st_update_framebuffer;
const struct st_tracked_state st_update_clip;
const struct st_tracked_state st_update_depth_stencil;
const struct st_tracked_state st_update_depth_stencil_alpha;
const struct st_tracked_state st_update_shader;
const struct st_tracked_state st_update_rasterizer;
const struct st_tracked_state st_update_polygon_stipple;
@@ -57,7 +57,6 @@ const struct st_tracked_state st_update_sampler;
const struct st_tracked_state st_update_texture;
const struct st_tracked_state st_update_fs_constants;
const struct st_tracked_state st_update_vs_constants;
const struct st_tracked_state st_update_alpha_test;
const struct st_tracked_state st_update_pixel_transfer;
@@ -1,92 +0,0 @@
/**************************************************************************
*
* 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.
*
**************************************************************************/
/*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
* Brian Paul
*/
#include "st_context.h"
#include "st_cache.h"
#include "st_atom.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
/**
* Convert GLenum stencil func tokens to pipe tokens.
*/
static GLuint
gl_alpha_func_to_sp(GLenum func)
{
/* Same values, just biased */
assert(PIPE_FUNC_NEVER == GL_NEVER - GL_NEVER);
assert(PIPE_FUNC_LESS == GL_LESS - GL_NEVER);
assert(PIPE_FUNC_EQUAL == GL_EQUAL - GL_NEVER);
assert(PIPE_FUNC_LEQUAL == GL_LEQUAL - GL_NEVER);
assert(PIPE_FUNC_GREATER == GL_GREATER - GL_NEVER);
assert(PIPE_FUNC_NOTEQUAL == GL_NOTEQUAL - GL_NEVER);
assert(PIPE_FUNC_GEQUAL == GL_GEQUAL - GL_NEVER);
assert(PIPE_FUNC_ALWAYS == GL_ALWAYS - GL_NEVER);
assert(func >= GL_NEVER);
assert(func <= GL_ALWAYS);
return func - GL_NEVER;
}
static void
update_alpha_test( struct st_context *st )
{
struct pipe_alpha_test_state alpha;
const struct cso_alpha_test *cso;
memset(&alpha, 0, sizeof(alpha));
if (st->ctx->Color.AlphaEnabled) {
alpha.enabled = 1;
alpha.func = gl_alpha_func_to_sp(st->ctx->Color.AlphaFunc);
alpha.ref = st->ctx->Color.AlphaRef;
}
cso = st_cached_alpha_test_state(st, &alpha);
if (st->state.alpha_test != cso) {
/* state has changed */
st->state.alpha_test = cso;
st->pipe->bind_alpha_test_state(st->pipe, cso->data); /* bind new state */
}
}
const struct st_tracked_state st_update_alpha_test = {
.name = "st_update_alpha_test",
.dirty = {
.mesa = (_NEW_COLOR),
.st = 0,
},
.update = update_alpha_test
};
+31 -24
View File
@@ -91,10 +91,10 @@ gl_stencil_op_to_pipe(GLenum func)
}
static void
update_depth_stencil(struct st_context *st)
update_depth_stencil_alpha(struct st_context *st)
{
struct pipe_depth_stencil_state depth_stencil;
const struct cso_depth_stencil *cso;
struct pipe_depth_stencil_alpha_state depth_stencil;
const struct cso_depth_stencil_alpha *cso;
memset(&depth_stencil, 0, sizeof(depth_stencil));
@@ -107,40 +107,47 @@ update_depth_stencil(struct st_context *st)
depth_stencil.depth.occlusion_count = 1;
if (st->ctx->Stencil.Enabled) {
depth_stencil.stencil.front_enabled = 1;
depth_stencil.stencil.front_func = st_compare_func_to_pipe(st->ctx->Stencil.Function[0]);
depth_stencil.stencil.front_fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[0]);
depth_stencil.stencil.front_zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[0]);
depth_stencil.stencil.front_zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[0]);
depth_stencil.stencil.ref_value[0] = st->ctx->Stencil.Ref[0] & 0xff;
depth_stencil.stencil.value_mask[0] = st->ctx->Stencil.ValueMask[0] & 0xff;
depth_stencil.stencil.write_mask[0] = st->ctx->Stencil.WriteMask[0] & 0xff;
depth_stencil.stencil[0].enabled = 1;
depth_stencil.stencil[0].func = st_compare_func_to_pipe(st->ctx->Stencil.Function[0]);
depth_stencil.stencil[0].fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[0]);
depth_stencil.stencil[0].zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[0]);
depth_stencil.stencil[0].zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[0]);
depth_stencil.stencil[0].ref_value = st->ctx->Stencil.Ref[0] & 0xff;
depth_stencil.stencil[0].value_mask = st->ctx->Stencil.ValueMask[0] & 0xff;
depth_stencil.stencil[0].write_mask = st->ctx->Stencil.WriteMask[0] & 0xff;
if (st->ctx->Stencil.TestTwoSide) {
depth_stencil.stencil.back_enabled = 1;
depth_stencil.stencil.back_func = st_compare_func_to_pipe(st->ctx->Stencil.Function[1]);
depth_stencil.stencil.back_fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[1]);
depth_stencil.stencil.back_zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[1]);
depth_stencil.stencil.back_zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[1]);
depth_stencil.stencil.ref_value[1] = st->ctx->Stencil.Ref[1] & 0xff;
depth_stencil.stencil.value_mask[1] = st->ctx->Stencil.ValueMask[1] & 0xff;
depth_stencil.stencil.write_mask[1] = st->ctx->Stencil.WriteMask[1] & 0xff;
depth_stencil.stencil[1].enabled = 1;
depth_stencil.stencil[1].func = st_compare_func_to_pipe(st->ctx->Stencil.Function[1]);
depth_stencil.stencil[1].fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[1]);
depth_stencil.stencil[1].zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[1]);
depth_stencil.stencil[1].zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[1]);
depth_stencil.stencil[1].ref_value = st->ctx->Stencil.Ref[1] & 0xff;
depth_stencil.stencil[1].value_mask = st->ctx->Stencil.ValueMask[1] & 0xff;
depth_stencil.stencil[1].write_mask = st->ctx->Stencil.WriteMask[1] & 0xff;
}
}
cso = st_cached_depth_stencil_state(st, &depth_stencil);
if (st->ctx->Color.AlphaEnabled) {
depth_stencil.alpha.enabled = 1;
depth_stencil.alpha.func = st_compare_func_to_pipe(st->ctx->Color.AlphaFunc);
depth_stencil.alpha.ref = st->ctx->Color.AlphaRef;
}
cso = st_cached_depth_stencil_alpha_state(st, &depth_stencil);
if (st->state.depth_stencil != cso) {
/* state has changed */
st->state.depth_stencil = cso;
st->pipe->bind_depth_stencil_state(st->pipe, cso->data); /* bind new state */
st->pipe->bind_depth_stencil_alpha_state(st->pipe, cso->data); /* bind new state */
}
}
const struct st_tracked_state st_update_depth_stencil = {
const struct st_tracked_state st_update_depth_stencil_alpha = {
.name = "st_update_depth_stencil",
.dirty = {
.mesa = (_NEW_DEPTH|_NEW_STENCIL),
.mesa = (_NEW_DEPTH|_NEW_STENCIL|_NEW_COLOR),
.st = 0,
},
.update = update_depth_stencil
.update = update_depth_stencil_alpha
};
+11 -29
View File
@@ -87,24 +87,25 @@ st_cached_sampler_state(struct st_context *st,
return (struct cso_sampler*)(cso_hash_iter_data(iter));
}
const struct cso_depth_stencil *
st_cached_depth_stencil_state(struct st_context *st,
const struct pipe_depth_stencil_state *templ)
const struct cso_depth_stencil_alpha *
st_cached_depth_stencil_alpha_state(struct st_context *st,
const struct pipe_depth_stencil_alpha_state *templ)
{
unsigned hash_key = cso_construct_key((void*)templ,
sizeof(struct pipe_depth_stencil_state));
sizeof(struct pipe_depth_stencil_alpha_state));
struct cso_hash_iter iter = cso_find_state_template(st->cache,
hash_key, CSO_DEPTH_STENCIL,
hash_key,
CSO_DEPTH_STENCIL_ALPHA,
(void*)templ);
if (cso_hash_iter_is_null(iter)) {
struct cso_depth_stencil *cso = malloc(sizeof(struct cso_depth_stencil));
memcpy(&cso->state, templ, sizeof(struct pipe_depth_stencil_state));
cso->data = st->pipe->create_depth_stencil_state(st->pipe, &cso->state);
struct cso_depth_stencil_alpha *cso = malloc(sizeof(struct cso_depth_stencil_alpha));
memcpy(&cso->state, templ, sizeof(struct pipe_depth_stencil_alpha_state));
cso->data = st->pipe->create_depth_stencil_alpha_state(st->pipe, &cso->state);
if (!cso->data)
cso->data = &cso->state;
iter = cso_insert_state(st->cache, hash_key, CSO_DEPTH_STENCIL, cso);
iter = cso_insert_state(st->cache, hash_key, CSO_DEPTH_STENCIL_ALPHA, cso);
}
return (struct cso_depth_stencil*)(cso_hash_iter_data(iter));
return (struct cso_depth_stencil_alpha*)(cso_hash_iter_data(iter));
}
const struct cso_rasterizer* st_cached_rasterizer_state(
@@ -167,22 +168,3 @@ st_cached_vs_state(struct st_context *st,
return (struct cso_vertex_shader*)(cso_hash_iter_data(iter));
}
const struct cso_alpha_test *
st_cached_alpha_test_state(struct st_context *st,
const struct pipe_alpha_test_state *templ)
{
unsigned hash_key = cso_construct_key((void*)templ,
sizeof(struct pipe_alpha_test_state));
struct cso_hash_iter iter = cso_find_state_template(st->cache,
hash_key, CSO_ALPHA_TEST,
(void*)templ);
if (cso_hash_iter_is_null(iter)) {
struct cso_alpha_test *cso = malloc(sizeof(struct cso_alpha_test));
memcpy(&cso->state, templ, sizeof(struct pipe_alpha_test_state));
cso->data = st->pipe->create_alpha_test_state(st->pipe, &cso->state);
if (!cso->data)
cso->data = &cso->state;
iter = cso_insert_state(st->cache, hash_key, CSO_ALPHA_TEST, cso);
}
return ((struct cso_alpha_test *)cso_hash_iter_data(iter));
}
+3 -6
View File
@@ -39,9 +39,6 @@ struct pipe_blend_state;
struct pipe_sampler_state;
struct st_context;
const struct cso_alpha_test *
st_cached_alpha_test_state(struct st_context *st,
const struct pipe_alpha_test_state *alpha);
const struct cso_blend *
st_cached_blend_state(struct st_context *st,
@@ -51,9 +48,9 @@ const struct cso_sampler *
st_cached_sampler_state(struct st_context *st,
const struct pipe_sampler_state *sampler);
const struct cso_depth_stencil *
st_cached_depth_stencil_state(struct st_context *st,
const struct pipe_depth_stencil_state *depth_stencil);
const struct cso_depth_stencil_alpha *
st_cached_depth_stencil_alpha_state(struct st_context *st,
const struct pipe_depth_stencil_alpha_state *depth_stencil);
const struct cso_rasterizer *
st_cached_rasterizer_state(struct st_context *st,
+13 -22
View File
@@ -272,14 +272,6 @@ clear_with_quad(GLcontext *ctx,
const GLfloat x1 = ctx->DrawBuffer->_Xmax;
const GLfloat y1 = ctx->DrawBuffer->_Ymax;
/* alpha state: disabled */
{
struct pipe_alpha_test_state alpha_test;
const struct cso_alpha_test *cso;
memset(&alpha_test, 0, sizeof(alpha_test));
cso = st_cached_alpha_test_state(st, &alpha_test);
pipe->bind_alpha_test_state(pipe, cso->data);
}
/* blend state: RGBA masking */
{
@@ -304,8 +296,8 @@ clear_with_quad(GLcontext *ctx,
/* depth_stencil state: always pass/set to ref value */
{
struct pipe_depth_stencil_state depth_stencil;
const struct cso_depth_stencil *cso;
struct pipe_depth_stencil_alpha_state depth_stencil;
const struct cso_depth_stencil_alpha *cso;
memset(&depth_stencil, 0, sizeof(depth_stencil));
if (depth) {
depth_stencil.depth.enabled = 1;
@@ -314,17 +306,17 @@ clear_with_quad(GLcontext *ctx,
}
if (stencil) {
depth_stencil.stencil.front_enabled = 1;
depth_stencil.stencil.front_func = PIPE_FUNC_ALWAYS;
depth_stencil.stencil.front_fail_op = PIPE_STENCIL_OP_REPLACE;
depth_stencil.stencil.front_zpass_op = PIPE_STENCIL_OP_REPLACE;
depth_stencil.stencil.front_zfail_op = PIPE_STENCIL_OP_REPLACE;
depth_stencil.stencil.ref_value[0] = ctx->Stencil.Clear;
depth_stencil.stencil.value_mask[0] = 0xff;
depth_stencil.stencil.write_mask[0] = ctx->Stencil.WriteMask[0] & 0xff;
depth_stencil.stencil[0].enabled = 1;
depth_stencil.stencil[0].func = PIPE_FUNC_ALWAYS;
depth_stencil.stencil[0].fail_op = PIPE_STENCIL_OP_REPLACE;
depth_stencil.stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE;
depth_stencil.stencil[0].zfail_op = PIPE_STENCIL_OP_REPLACE;
depth_stencil.stencil[0].ref_value = ctx->Stencil.Clear;
depth_stencil.stencil[0].value_mask = 0xff;
depth_stencil.stencil[0].write_mask = ctx->Stencil.WriteMask[0] & 0xff;
}
cso = st_cached_depth_stencil_state(st, &depth_stencil);
pipe->bind_depth_stencil_state(pipe, cso->data);
cso = st_cached_depth_stencil_alpha_state(st, &depth_stencil);
pipe->bind_depth_stencil_alpha_state(pipe, cso->data);
}
/* rasterizer state: nothing */
@@ -381,9 +373,8 @@ clear_with_quad(GLcontext *ctx,
draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor);
/* Restore pipe state */
pipe->bind_alpha_test_state(pipe, st->state.alpha_test->data);
pipe->bind_blend_state(pipe, st->state.blend->data);
pipe->bind_depth_stencil_state(pipe, st->state.depth_stencil->data);
pipe->bind_depth_stencil_alpha_state(pipe, st->state.depth_stencil->data);
pipe->bind_fs_state(pipe, st->state.fs->data);
pipe->bind_vs_state(pipe, st->state.vs->data);
pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data);
+1 -1
View File
@@ -789,7 +789,7 @@ compatible_formats(GLenum format, GLenum type, enum pipe_format pipeFormat)
static GLboolean
any_fragment_ops(const struct st_context *st)
{
if (st->state.alpha_test->state.enabled ||
if (st->state.depth_stencil->state.alpha.enabled ||
st->state.blend->state.blend_enable ||
st->state.blend->state.logicop_enable ||
st->state.depth_stencil->state.depth.enabled)
+1 -1
View File
@@ -97,7 +97,7 @@ struct st_context
const struct cso_alpha_test *alpha_test;
const struct cso_blend *blend;
const struct cso_sampler *sampler[PIPE_MAX_SAMPLERS];
const struct cso_depth_stencil *depth_stencil;
const struct cso_depth_stencil_alpha *depth_stencil;
const struct cso_rasterizer *rasterizer;
const struct cso_fragment_shader *fs;
const struct cso_vertex_shader *vs;
+57 -1
View File
@@ -597,6 +597,19 @@ make_sampler_decl(GLuint index)
return decl;
}
/** Reference into a constant buffer */
static struct tgsi_full_declaration
make_constant_decl(GLuint first, GLuint last)
{
struct tgsi_full_declaration decl;
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_CONSTANT;
decl.Declaration.Declare = TGSI_DECLARE_RANGE;
decl.u.DeclarationRange.First = first;
decl.u.DeclarationRange.Last = last;
return decl;
}
/**
@@ -788,7 +801,7 @@ tgsi_translate_mesa_program(
/* immediates/literals */
for (i = 0; program->Parameters && i < program->Parameters->NumParameters;
i++) {
i++) {
if (program->Parameters->Parameters[i].Type == PROGRAM_CONSTANT) {
struct tgsi_full_immediate fullimm
= make_immediate(program->Parameters->ParameterValues[i],
@@ -802,6 +815,49 @@ tgsi_translate_mesa_program(
}
}
/* constant buffer refs */
{
GLint start = -1, end = -1;
for (i = 0;
program->Parameters && i < program->Parameters->NumParameters;
i++) {
GLboolean emit = (i == program->Parameters->NumParameters - 1);
switch (program->Parameters->Parameters[i].Type) {
case PROGRAM_ENV_PARAM:
case PROGRAM_STATE_VAR:
case PROGRAM_NAMED_PARAM:
case PROGRAM_UNIFORM:
if (start == -1) {
/* begin a sequence */
start = i;
end = i;
}
else {
/* continue sequence */
end = i;
}
break;
default:
if (start != -1) {
/* end of sequence */
emit = GL_TRUE;
}
}
if (emit && start >= 0) {
struct tgsi_full_declaration fulldecl;
fulldecl = make_constant_decl( start, end );
ti += tgsi_build_full_declaration(&fulldecl,
&tokens[ti],
header,
maxTokens - ti);
start = end = -1;
}
}
}
/* texture samplers */
for (i = 0; i < 8; i++) {
if (program->SamplersUsed & (1 << i)) {