Commit be7af29d authored by Keith Whitwell's avatar Keith Whitwell

Merge commit 'origin/master' into gallium-resources

Conflicts:
	src/gallium/auxiliary/cso_cache/cso_context.c
	src/gallium/auxiliary/cso_cache/cso_context.h
	src/gallium/drivers/r300/r300_context.c
	src/gallium/drivers/r300/r300_render.c
	src/gallium/drivers/r300/r300_state.c
	src/gallium/drivers/r300/r300_state_derived.c
	src/gallium/state_trackers/vega/api_filters.c
	src/gallium/state_trackers/vega/image.c
	src/gallium/state_trackers/vega/image.h
	src/gallium/state_trackers/vega/mask.c
	src/gallium/state_trackers/vega/mask.h
	src/gallium/state_trackers/vega/paint.c
	src/gallium/state_trackers/vega/paint.h
	src/gallium/state_trackers/vega/renderer.c
	src/gallium/state_trackers/vega/renderer.h
	src/gallium/state_trackers/vega/shader.c
	src/gallium/state_trackers/vega/vg_context.h
	src/gallium/state_trackers/vega/vg_tracker.c
	src/mesa/state_tracker/st_manager.c
parents d22c2c6c 12deb9e6
......@@ -16,6 +16,7 @@ GLSL changes (GL_EXT_gpu_shader4, etc) not started
Conditional rendering (GL_NV_conditional_render) DONE (swrast & softpipe)
Map buffer subranges (GL_APPLE_flush_buffer_range) not started
Float textures, renderbuffers some infrastructure done
(incl. GL_EXT_packed_float, GL_EXT_shared_exponent)
Framebuffer objects (GL_EXT_framebuffer_object) DONE
Half-float some infrastructure done
Multisample blit DONE
......
......@@ -26,7 +26,7 @@
* \file stencil_twoside.c
*
* Simple test of GL_ATI_separate_stencil (or the OGL 2.0 equivalent) functionality.
* Four squares are drawn
* Five squares (or six if stencil wrap is available) are drawn
* with different stencil modes, but all should be rendered with the same
* final color.
*/
......@@ -37,7 +37,7 @@
#include <GL/glut.h>
static int use20syntax = 1;
static int Width = 550;
static int Width = 650;
static int Height = 200;
static const GLfloat Near = 5.0, Far = 25.0;
......@@ -70,7 +70,7 @@ static void Display( void )
*/
glDisable(GL_STENCIL_TEST);
glTranslatef(-6.0, 0, 0);
glTranslatef(-7.0, 0, 0);
glBegin(GL_QUADS);
glColor3f( 0.5, 0.5, 0.5 );
glVertex2f(-1, -1);
......@@ -85,6 +85,9 @@ static void Display( void )
/* Draw the first two squares using incr for the affected face
*/
/*************************************************************************
* 2nd square
*/
if (use20syntax) {
stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0);
stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
......@@ -98,8 +101,8 @@ static void Display( void )
glTranslatef(3.0, 0, 0);
glBegin(GL_QUADS);
glColor3f( 0.9, 0.9, 0.9 );
/* this should be front facing */
for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
/* this should be front facing */
glVertex2f(-1, -1);
glVertex2f( 1, -1);
glVertex2f( 1, 1);
......@@ -107,6 +110,7 @@ static void Display( void )
}
glEnd();
/* stencil vals should be equal to max_stencil */
glStencilFunc(GL_EQUAL, max_stencil, ~0);
glBegin(GL_QUADS);
glColor3f( 0.5, 0.5, 0.5 );
......@@ -116,6 +120,9 @@ static void Display( void )
glVertex2f(-1, 1);
glEnd();
/*************************************************************************
* 3rd square
*/
if (use20syntax) {
stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0);
stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
......@@ -129,9 +136,8 @@ static void Display( void )
glTranslatef(3.0, 0, 0);
glBegin(GL_QUADS);
glColor3f( 0.9, 0.9, 0.9 );
/* this should be back facing */
for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
/* this should be back facing */
glVertex2f(-1, -1);
glVertex2f(-1, 1);
glVertex2f( 1, 1);
......@@ -139,6 +145,7 @@ static void Display( void )
}
glEnd();
/* stencil vals should be equal to max_stencil */
glStencilFunc(GL_EQUAL, max_stencil, ~0);
glBegin(GL_QUADS);
glColor3f( 0.5, 0.5, 0.5 );
......@@ -148,6 +155,9 @@ static void Display( void )
glVertex2f(-1, 1);
glEnd();
/*************************************************************************
* 4th square
*/
if (use20syntax) {
stencil_func_separate(GL_FRONT, GL_NEVER, 0, ~0);
stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
......@@ -161,15 +171,13 @@ static void Display( void )
glTranslatef(3.0, 0, 0);
glBegin(GL_QUADS);
glColor3f( 0.9, 0.9, 0.9 );
/* this should be back facing */
for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
/* this should be back facing */
/* this should be back facing */
glVertex2f(-1, -1);
glVertex2f(-1, 1);
glVertex2f( 1, 1);
glVertex2f( 1, -1);
/* this should be front facing */
/* this should be front facing */
glVertex2f(-1, -1);
glVertex2f( 1, -1);
glVertex2f( 1, 1);
......@@ -177,6 +185,7 @@ static void Display( void )
}
glEnd();
/* stencil vals should be equal to max_stencil */
glStencilFunc(GL_EQUAL, max_stencil, ~0);
glBegin(GL_QUADS);
glColor3f( 0.5, 0.5, 0.5 );
......@@ -186,6 +195,9 @@ static void Display( void )
glVertex2f(-1, 1);
glEnd();
/*************************************************************************
* 5th square
*/
if (use20syntax) {
stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0);
stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
......@@ -193,21 +205,19 @@ static void Display( void )
else {
stencil_func_separate_ati(GL_ALWAYS, GL_ALWAYS, 0, ~0);
}
stencil_op_separate(GL_FRONT, GL_KEEP, GL_KEEP, GL_DECR);
stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_INCR);
stencil_op_separate(GL_FRONT, GL_KEEP, GL_KEEP, GL_INCR);
stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_DECR);
glTranslatef(3.0, 0, 0);
glBegin(GL_QUADS);
glColor3f( 0.9, 0.9, 0.9 );
/* this should be back facing */
for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
/* this should be back facing */
/* this should be back facing */
glVertex2f(-1, -1);
glVertex2f(-1, 1);
glVertex2f( 1, 1);
glVertex2f( 1, -1);
/* this should be front facing */
/* this should be front facing */
glVertex2f(-1, -1);
glVertex2f( 1, -1);
glVertex2f( 1, 1);
......@@ -224,6 +234,47 @@ static void Display( void )
glVertex2f(-1, 1);
glEnd();
/*************************************************************************
* 6th square
*/
if (glutExtensionSupported("GL_EXT_stencil_wrap")) {
if (use20syntax) {
stencil_func_separate(GL_FRONT, GL_ALWAYS, 0, ~0);
stencil_func_separate(GL_BACK, GL_ALWAYS, 0, ~0);
}
else {
stencil_func_separate_ati(GL_ALWAYS, GL_ALWAYS, 0, ~0);
}
stencil_op_separate(GL_FRONT, GL_KEEP, GL_KEEP, GL_KEEP);
stencil_op_separate(GL_BACK, GL_KEEP, GL_KEEP, GL_INCR_WRAP);
glTranslatef(3.0, 0, 0);
glBegin(GL_QUADS);
glColor3f( 0.9, 0.9, 0.9 );
for ( i = 0 ; i < (max_stencil + 5) ; i++ ) {
/* this should be back facing */
glVertex2f(-1, -1);
glVertex2f(-1, 1);
glVertex2f( 1, 1);
glVertex2f( 1, -1);
/* this should be front facing */
glVertex2f(-1, -1);
glVertex2f( 1, -1);
glVertex2f( 1, 1);
glVertex2f(-1, 1);
}
glEnd();
glStencilFunc(GL_EQUAL, 260 - 255, ~0);
glBegin(GL_QUADS);
glColor3f( 0.5, 0.5, 0.5 );
glVertex2f(-1, -1);
glVertex2f( 1, -1);
glVertex2f( 1, 1);
glVertex2f(-1, 1);
glEnd();
}
glPopMatrix();
glutSwapBuffers();
......@@ -278,7 +329,7 @@ static void Init( void )
stencil_func_separate_ati = (PFNGLSTENCILFUNCSEPARATEATIPROC) glutGetProcAddress( "glStencilFuncSeparateATI" );
stencil_op_separate = (PFNGLSTENCILOPSEPARATEPROC) glutGetProcAddress( "glStencilOpSeparate" );
printf("\nAll 5 squares should be the same color.\n");
printf("\nAll 5 (or 6) squares should be the same color.\n");
}
......
......@@ -618,74 +618,6 @@ cso_restore_vertex_samplers(struct cso_context *ctx)
}
enum pipe_error cso_set_sampler_textures( struct cso_context *ctx,
uint count,
struct pipe_resource **textures )
{
uint i;
ctx->nr_fragment_sampler_views = count;
for (i = 0; i < count; i++) {
struct pipe_sampler_view templ, *view;
u_sampler_view_default_template(&templ,
textures[i],
textures[i]->format);
view = ctx->pipe->create_sampler_view(ctx->pipe,
textures[i],
&templ);
pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], view);
}
for ( ; i < PIPE_MAX_SAMPLERS; i++) {
pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], NULL);
}
ctx->pipe->set_fragment_sampler_views(ctx->pipe,
count,
ctx->fragment_sampler_views);
return PIPE_OK;
}
void cso_save_sampler_textures( struct cso_context *ctx )
{
uint i;
ctx->nr_fragment_sampler_views_saved = ctx->nr_fragment_sampler_views;
for (i = 0; i < ctx->nr_fragment_sampler_views; i++) {
assert(!ctx->fragment_sampler_views_saved[i]);
pipe_sampler_view_reference(&ctx->fragment_sampler_views_saved[i],
ctx->fragment_sampler_views[i]);
}
}
void cso_restore_sampler_textures( struct cso_context *ctx )
{
uint i;
ctx->nr_fragment_sampler_views = ctx->nr_fragment_sampler_views_saved;
for (i = 0; i < ctx->nr_fragment_sampler_views; i++) {
pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], NULL);
ctx->fragment_sampler_views[i] = ctx->fragment_sampler_views_saved[i];
ctx->fragment_sampler_views_saved[i] = NULL;
}
for ( ; i < PIPE_MAX_SAMPLERS; i++) {
pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], NULL);
}
ctx->pipe->set_fragment_sampler_views(ctx->pipe,
ctx->nr_fragment_sampler_views,
ctx->fragment_sampler_views);
ctx->nr_fragment_sampler_views_saved = 0;
}
enum pipe_error cso_set_depth_stencil_alpha(struct cso_context *ctx,
const struct pipe_depth_stencil_alpha_state *templ)
{
......
......@@ -103,14 +103,6 @@ void
cso_single_vertex_sampler_done(struct cso_context *cso);
enum pipe_error cso_set_sampler_textures( struct cso_context *cso,
uint count,
struct pipe_resource **textures );
void cso_save_sampler_textures( struct cso_context *cso );
void cso_restore_sampler_textures( struct cso_context *cso );
enum pipe_error cso_set_vertex_elements(struct cso_context *ctx,
unsigned count,
const struct pipe_vertex_element *states);
......
......@@ -57,9 +57,10 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder,
struct lp_type type,
const struct util_format_description *format_desc,
struct lp_build_mask_context *mask,
LLVMValueRef stencil_refs,
LLVMValueRef stencil_refs[2],
LLVMValueRef zs_src,
LLVMValueRef zs_dst_ptr);
LLVMValueRef zs_dst_ptr,
LLVMValueRef facing);
#endif /* !LP_BLD_DEPTH_H */
......@@ -63,6 +63,7 @@ PIPE_FORMAT_A8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, r
PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, rgb
PIPE_FORMAT_A8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb
PIPE_FORMAT_X8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb
PIPE_FORMAT_B5G5R5X1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyx1, rgb
PIPE_FORMAT_B5G5R5A1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb
PIPE_FORMAT_B4G4R4A4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb
PIPE_FORMAT_B5G6R5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb
......
......@@ -120,6 +120,13 @@ util_format_test_cases[] =
* 16-bit rendertarget formats
*/
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 0.0}},
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x001f), {0.0, 0.0, 1.0, 0.0}},
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x03e0), {0.0, 1.0, 0.0, 0.0}},
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x7c00), {1.0, 0.0, 0.0, 0.0}},
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x8000), {0.0, 0.0, 0.0, 1.0}},
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0xffff), {1.0, 1.0, 1.0, 1.0}},
{PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 0.0}},
{PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x001f), {0.0, 0.0, 1.0, 0.0}},
{PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x03e0), {0.0, 1.0, 0.0, 0.0}},
......
......@@ -938,6 +938,7 @@ format_to_type_comps(enum pipe_format pformat,
*datatype = DTYPE_UBYTE;
*comps = 4;
return;
case PIPE_FORMAT_B5G5R5X1_UNORM:
case PIPE_FORMAT_B5G5R5A1_UNORM:
*datatype = DTYPE_USHORT_1_5_5_5_REV;
*comps = 4;
......
......@@ -92,6 +92,11 @@ util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a,
uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
}
return;
case PIPE_FORMAT_B5G5R5X1_UNORM:
{
uc->us = ((0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
}
return;
case PIPE_FORMAT_B5G5R5A1_UNORM:
{
uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
......@@ -216,6 +221,15 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc,
*a = (ubyte) 0xff;
}
return;
case PIPE_FORMAT_B5G5R5X1_UNORM:
{
ushort p = uc->us;
*r = (ubyte) (((p >> 7) & 0xf8) | ((p >> 12) & 0x7));
*g = (ubyte) (((p >> 2) & 0xf8) | ((p >> 7) & 0x7));
*b = (ubyte) (((p << 3) & 0xf8) | ((p >> 2) & 0x7));
*a = (ubyte) 0xff;
}
return;
case PIPE_FORMAT_B5G5R5A1_UNORM:
{
ushort p = uc->us;
......@@ -361,6 +375,11 @@ util_pack_color(const float rgba[4], enum pipe_format format, union util_color *
uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3);
}
return;
case PIPE_FORMAT_B5G5R5X1_UNORM:
{
uc->us = ((0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
}
return;
case PIPE_FORMAT_B5G5R5A1_UNORM:
{
uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3);
......
......@@ -295,6 +295,55 @@ r8g8b8a8_put_tile_rgba(unsigned *dst,
}
/*** PIPE_FORMAT_B5G5R5X1_UNORM ***/
static void
x1r5g5b5_get_tile_rgba(const ushort *src,
unsigned w, unsigned h,
float *p,
unsigned dst_stride)
{
unsigned i, j;
for (i = 0; i < h; i++) {
float *pRow = p;
for (j = 0; j < w; j++, pRow += 4) {
const ushort pixel = *src++;
pRow[0] = ((pixel >> 10) & 0x1f) * (1.0f / 31.0f);
pRow[1] = ((pixel >> 5) & 0x1f) * (1.0f / 31.0f);
pRow[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f);
pRow[3] = 1.0f;
}
p += dst_stride;
}
}
static void
x1r5g5b5_put_tile_rgba(ushort *dst,
unsigned w, unsigned h,
const float *p,
unsigned src_stride)
{
unsigned i, j;
for (i = 0; i < h; i++) {
const float *pRow = p;
for (j = 0; j < w; j++, pRow += 4) {
unsigned r, g, b;
r = float_to_ubyte(pRow[0]);
g = float_to_ubyte(pRow[1]);
b = float_to_ubyte(pRow[2]);
r = r >> 3; /* 5 bits */
g = g >> 3; /* 5 bits */
b = b >> 3; /* 5 bits */
*dst++ = (1 << 15) | (r << 10) | (g << 5) | b;
}
p += src_stride;
}
}
/*** PIPE_FORMAT_B5G5R5A1_UNORM ***/
static void
......@@ -1174,6 +1223,9 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
case PIPE_FORMAT_A8B8G8R8_UNORM:
r8g8b8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride);
break;
case PIPE_FORMAT_B5G5R5X1_UNORM:
x1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride);
break;
case PIPE_FORMAT_B5G5R5A1_UNORM:
a1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride);
break;
......@@ -1368,6 +1420,9 @@ pipe_put_tile_rgba(struct pipe_context *pipe,
case PIPE_FORMAT_A8B8G8R8_UNORM:
r8g8b8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
break;
case PIPE_FORMAT_B5G5R5X1_UNORM:
x1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
break;
case PIPE_FORMAT_B5G5R5A1_UNORM:
a1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
break;
......
......@@ -50,6 +50,7 @@ Non-CSO State
These pieces of state are too small, variable, and/or trivial to have CSO
objects. They all follow simple, one-method binding calls, e.g.
``set_blend_color``.
* ``set_stencil_ref`` sets the stencil front and back reference values
which are used as comparison values in stencil test.
* ``set_blend_color``
......@@ -73,11 +74,11 @@ is being cast to another format. Casting can be done only between compatible
formats, that is formats that have matching component order and sizes.
Swizzle fields specify they way in which fetched texel components are placed
in the result register. For example, swizzle_r specifies what is going to be
placed in destination register x (AKA r).
in the result register. For example, ``swizzle_r`` specifies what is going to be
placed in first component of result register.
first_level and last_level fields of sampler view template specify the LOD
range the texture is going to be constrained to.
The ``first_level`` and ``last_level`` fields of sampler view template specify
the LOD range the texture is going to be constrained to.
* ``set_fragment_sampler_views`` binds an array of sampler views to
fragment shader stage. Every binding point acquires a reference
......@@ -88,7 +89,7 @@ range the texture is going to be constrained to.
shader stage. Every binding point acquires a reference to a respective
sampler view and releases a reference to the previous sampler view.
* ``create_sampler_view`` creates a new sampler view. texture is associated
* ``create_sampler_view`` creates a new sampler view. ``texture`` is associated
with the sampler view which results in sampler view holding a reference
to the texture. Format specified in template must be compatible
with texture format.
......
.. _vertex,elements
.. _vertexelements:
Vertex Elements
===============
......
......@@ -96,7 +96,8 @@ lp_jit_init_globals(struct llvmpipe_screen *screen)
elem_types[LP_JIT_CTX_CONSTANTS] = LLVMPointerType(LLVMFloatType(), 0);
elem_types[LP_JIT_CTX_ALPHA_REF] = LLVMFloatType();
elem_types[LP_JIT_CTX_STENCIL_REF] = LLVMArrayType(LLVMInt8Type(), 2);
elem_types[LP_JIT_CTX_STENCIL_REF_FRONT] = LLVMInt32Type();
elem_types[LP_JIT_CTX_STENCIL_REF_BACK] = LLVMInt32Type();
elem_types[LP_JIT_CTX_SCISSOR_XMIN] = LLVMFloatType();
elem_types[LP_JIT_CTX_SCISSOR_YMIN] = LLVMFloatType();
elem_types[LP_JIT_CTX_SCISSOR_XMAX] = LLVMFloatType();
......@@ -113,9 +114,12 @@ lp_jit_init_globals(struct llvmpipe_screen *screen)
LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, alpha_ref_value,
screen->target, context_type,
LP_JIT_CTX_ALPHA_REF);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, stencil_ref,
LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, stencil_ref_front,
screen->target, context_type,
LP_JIT_CTX_STENCIL_REF);
LP_JIT_CTX_STENCIL_REF_FRONT);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, stencil_ref_back,
screen->target, context_type,
LP_JIT_CTX_STENCIL_REF_BACK);
LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, scissor_xmin,
screen->target, context_type,
LP_JIT_CTX_SCISSOR_XMIN);
......
......@@ -84,7 +84,7 @@ struct lp_jit_context
float alpha_ref_value;
uint8_t stencil_ref[2];
uint32_t stencil_ref_front, stencil_ref_back;
/** floats, not ints */
float scissor_xmin, scissor_ymin, scissor_xmax, scissor_ymax;
......@@ -103,7 +103,8 @@ struct lp_jit_context
enum {
LP_JIT_CTX_CONSTANTS = 0,
LP_JIT_CTX_ALPHA_REF,
LP_JIT_CTX_STENCIL_REF,
LP_JIT_CTX_STENCIL_REF_FRONT,
LP_JIT_CTX_STENCIL_REF_BACK,
LP_JIT_CTX_SCISSOR_XMIN,
LP_JIT_CTX_SCISSOR_YMIN,
LP_JIT_CTX_SCISSOR_XMAX,
......@@ -120,8 +121,11 @@ enum {
#define lp_jit_context_alpha_ref_value(_builder, _ptr) \
lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_ALPHA_REF, "alpha_ref_value")
#define lp_jit_context_stencil_ref_values(_builder, _ptr) \
lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CTX_STENCIL_REF, "stencil_ref")
#define lp_jit_context_stencil_ref_front_value(_builder, _ptr) \
lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_STENCIL_REF_FRONT, "stencil_ref_front")
#define lp_jit_context_stencil_ref_back_value(_builder, _ptr) \
lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_STENCIL_REF_BACK, "stencil_ref_back")
#define lp_jit_context_scissor_xmin_value(_builder, _ptr) \
lp_build_struct_get(_builder, _ptr, LP_JIT_CTX_SCISSOR_XMIN, "scissor_xmin")
......@@ -142,10 +146,16 @@ enum {
lp_build_struct_get_ptr(_builder, _ptr, LP_JIT_CONTEXT_TEXTURES, "textures")
/** Indexes into jit_function[] array */
#define RAST_WHOLE 0
#define RAST_EDGE_TEST 1
typedef void
(*lp_jit_frag_func)(const struct lp_jit_context *context,
uint32_t x,
uint32_t y,
float facing,
const void *a0,
const void *dadx,
const void *dady,
......
......@@ -312,15 +312,16 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task,
depth = lp_rast_depth_pointer(rast, tile_x + x, tile_y + y);
/* run shader */
state->jit_function[0]( &state->jit_context,
tile_x + x, tile_y + y,
inputs->a0,
inputs->dadx,
inputs->dady,
color,
depth,
INT_MIN, INT_MIN, INT_MIN,
NULL, NULL, NULL );
state->jit_function[RAST_WHOLE]( &state->jit_context,
tile_x + x, tile_y + y,
inputs->facing,
inputs->a0,
inputs->dadx,
inputs->dady,
color,
depth,
INT_MIN, INT_MIN, INT_MIN,
NULL, NULL, NULL );
}
}
}
......@@ -375,15 +376,18 @@ void lp_rast_shade_quads( struct lp_rasterizer_task *task,
assert(lp_check_alignment(inputs->step[2], 16));
/* run shader */
state->jit_function[1]( &state->jit_context,
x, y,
inputs->a0,
inputs->dadx,
inputs->dady,
color,
depth,
c1, c2, c3,
inputs->step[0], inputs->step[1], inputs->step[2]);
state->jit_function[RAST_EDGE_TEST]( &state->jit_context,
x, y,
inputs->facing,
inputs->a0,
inputs->dadx,
inputs->dady,
color,
depth,
c1, c2, c3,
inputs->step[0],
inputs->step[1],
inputs->step[2]);
}
......
......@@ -82,6 +82,8 @@ struct lp_rast_state {
* These pointers point into the bin data buffer.
*/
struct lp_rast_shader_inputs {
float facing; /** Positive for front-facing, negative for back-facing */
float (*a0)[4];
float (*dadx)[4];
float (*dady)[4];
......
......@@ -195,6 +195,7 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task,
/* run shader */
state->jit_function[0]( &state->jit_context,
x, y,
inputs->facing,
inputs->a0,
inputs->dadx,
inputs->dady,
......
......@@ -406,10 +406,10 @@ lp_setup_set_stencil_ref_values( struct lp_setup_context *setup,
{
LP_DBG(DEBUG_SETUP, "%s %d %d\n", __FUNCTION__, refs[0], refs[1]);
if (setup->fs.current.jit_context.stencil_ref[0] != refs[0] ||
setup->fs.current.jit_context.stencil_ref[1] != refs[1]) {
setup->fs.current.jit_context.stencil_ref[0] = refs[0];
setup->fs.current.jit_context.stencil_ref[1] = refs[1];
if (setup->fs.current.jit_context.stencil_ref_front != refs[0] ||
setup->fs.current.jit_context.stencil_ref_back != refs[1]) {
setup->fs.current.jit_context.stencil_ref_front = refs[0];
setup->fs.current.jit_context.stencil_ref_back = refs[1];
setup->dirty |= LP_SETUP_NEW_FS;
}
}
......
......@@ -361,6 +361,8 @@ do_triangle_ccw(struct lp_setup_context *setup,
*/
setup_tri_coefficients( setup, tri, oneoverarea, v1, v2, v3, frontfacing );
tri->inputs.facing = frontfacing ? 1.0F : -1.0F;
/* half-edge constants, will be interated over the whole render target.
*/
t