gallium: more work for edgeflags changes
fixes, cleanups, etc. not working yet
This commit is contained in:
@@ -182,6 +182,7 @@ struct draw_context
|
|||||||
struct draw_vertex_shader *vertex_shader;
|
struct draw_vertex_shader *vertex_shader;
|
||||||
uint num_vs_outputs; /**< convenience, from vertex_shader */
|
uint num_vs_outputs; /**< convenience, from vertex_shader */
|
||||||
uint position_output;
|
uint position_output;
|
||||||
|
uint edgeflag_output;
|
||||||
|
|
||||||
/** TGSI program interpreter runtime state */
|
/** TGSI program interpreter runtime state */
|
||||||
struct tgsi_exec_machine *machine;
|
struct tgsi_exec_machine *machine;
|
||||||
|
@@ -314,14 +314,3 @@ draw_arrays(struct draw_context *draw, unsigned prim,
|
|||||||
/* drawing done here: */
|
/* drawing done here: */
|
||||||
draw_pt_arrays(draw, prim, start, count);
|
draw_pt_arrays(draw, prim, start, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean draw_pt_get_edgeflag( struct draw_context *draw,
|
|
||||||
unsigned idx )
|
|
||||||
{
|
|
||||||
if (draw->pt.user.edgeflag) {
|
|
||||||
float *ef = draw->pt.verted_buffer[idx]
|
|
||||||
return (draw->pt.user.edgeflag[idx/32] & (1 << (idx%32))) != 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
@@ -212,7 +212,8 @@ boolean draw_pt_post_vs_run( struct pt_post_vs *pvs,
|
|||||||
void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
|
void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
|
||||||
boolean bypass_clipping,
|
boolean bypass_clipping,
|
||||||
boolean bypass_viewport,
|
boolean bypass_viewport,
|
||||||
boolean opengl );
|
boolean opengl,
|
||||||
|
boolean need_edgeflags );
|
||||||
|
|
||||||
struct pt_post_vs *draw_pt_post_vs_create( struct draw_context *draw );
|
struct pt_post_vs *draw_pt_post_vs_create( struct draw_context *draw );
|
||||||
|
|
||||||
|
@@ -42,11 +42,11 @@ struct pt_fetch {
|
|||||||
struct translate *translate;
|
struct translate *translate;
|
||||||
|
|
||||||
unsigned vertex_size;
|
unsigned vertex_size;
|
||||||
boolean need_edgeflags;
|
|
||||||
|
|
||||||
struct translate_cache *cache;
|
struct translate_cache *cache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Perform the fetch from API vertex elements & vertex buffers, to a
|
/* Perform the fetch from API vertex elements & vertex buffers, to a
|
||||||
* contiguous set of float[4] attributes as required for the
|
* contiguous set of float[4] attributes as required for the
|
||||||
* vertex_shader->run_linear() method.
|
* vertex_shader->run_linear() method.
|
||||||
@@ -160,11 +160,6 @@ void draw_pt_fetch_run( struct pt_fetch *fetch,
|
|||||||
count,
|
count,
|
||||||
verts );
|
verts );
|
||||||
|
|
||||||
/* Extract edgeflag values from vertex data into the header.
|
|
||||||
*/
|
|
||||||
if (fetch->need_edgeflags) {
|
|
||||||
extract_edge_flags( fetch, count );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -189,14 +184,6 @@ void draw_pt_fetch_run_linear( struct pt_fetch *fetch,
|
|||||||
start,
|
start,
|
||||||
count,
|
count,
|
||||||
verts );
|
verts );
|
||||||
|
|
||||||
/* Extract edgeflag values from vertex data into the header. XXX:
|
|
||||||
* this should be done after the vertex shader is run.
|
|
||||||
* Bypass-vs-and-clip interaction with pipeline???
|
|
||||||
*/
|
|
||||||
if (fetch->need_edgeflags) {
|
|
||||||
extract_edge_flags( fetch, count );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -85,10 +85,9 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle,
|
|||||||
draw_pt_post_vs_prepare( fpme->post_vs,
|
draw_pt_post_vs_prepare( fpme->post_vs,
|
||||||
(boolean)draw->bypass_clipping,
|
(boolean)draw->bypass_clipping,
|
||||||
(boolean)(draw->identity_viewport ||
|
(boolean)(draw->identity_viewport ||
|
||||||
draw->rasterizer->bypass_vs_clip_and_viewport),
|
draw->rasterizer->bypass_vs_clip_and_viewport),
|
||||||
(boolean)draw->rasterizer->gl_rasterization_rules,
|
(boolean)draw->rasterizer->gl_rasterization_rules,
|
||||||
need_edgeflags );
|
(draw->vs.edgeflag_output ? true : false) );
|
||||||
|
|
||||||
|
|
||||||
if (!(opt & PT_PIPELINE)) {
|
if (!(opt & PT_PIPELINE)) {
|
||||||
draw_pt_emit_prepare( fpme->emit,
|
draw_pt_emit_prepare( fpme->emit,
|
||||||
|
@@ -155,6 +155,7 @@ post_vs_cliptest_viewport_gl_edgeflag(struct pt_post_vs *pvs,
|
|||||||
unsigned count,
|
unsigned count,
|
||||||
unsigned stride )
|
unsigned stride )
|
||||||
{
|
{
|
||||||
|
unsigned j;
|
||||||
if (!post_vs_cliptest_viewport_gl( pvs, vertices, count, stride))
|
if (!post_vs_cliptest_viewport_gl( pvs, vertices, count, stride))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@@ -170,6 +171,7 @@ post_vs_cliptest_viewport_gl_edgeflag(struct pt_post_vs *pvs,
|
|||||||
out->edgeflag = (edgeflag[0] != 1.0f);
|
out->edgeflag = (edgeflag[0] != 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -229,7 +231,8 @@ boolean draw_pt_post_vs_run( struct pt_post_vs *pvs,
|
|||||||
void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
|
void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
|
||||||
boolean bypass_clipping,
|
boolean bypass_clipping,
|
||||||
boolean bypass_viewport,
|
boolean bypass_viewport,
|
||||||
boolean opengl )
|
boolean opengl,
|
||||||
|
boolean need_edgeflags )
|
||||||
{
|
{
|
||||||
if (!need_edgeflags) {
|
if (!need_edgeflags) {
|
||||||
if (bypass_clipping) {
|
if (bypass_clipping) {
|
||||||
|
@@ -101,6 +101,9 @@ draw_create_vertex_shader(struct draw_context *draw,
|
|||||||
if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_POSITION &&
|
if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_POSITION &&
|
||||||
vs->info.output_semantic_index[i] == 0)
|
vs->info.output_semantic_index[i] == 0)
|
||||||
vs->position_output = i;
|
vs->position_output = i;
|
||||||
|
else if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_EDGEFLAG &&
|
||||||
|
vs->info.output_semantic_index[i] == 0)
|
||||||
|
vs->edgeflag_output = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +123,7 @@ draw_bind_vertex_shader(struct draw_context *draw,
|
|||||||
draw->vs.vertex_shader = dvs;
|
draw->vs.vertex_shader = dvs;
|
||||||
draw->vs.num_vs_outputs = dvs->info.num_outputs;
|
draw->vs.num_vs_outputs = dvs->info.num_outputs;
|
||||||
draw->vs.position_output = dvs->position_output;
|
draw->vs.position_output = dvs->position_output;
|
||||||
|
draw->vs.edgeflag_output = dvs->edgeflag_output;
|
||||||
dvs->prepare( dvs, draw );
|
dvs->prepare( dvs, draw );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@@ -107,6 +107,7 @@ struct draw_vertex_shader {
|
|||||||
|
|
||||||
struct tgsi_shader_info info;
|
struct tgsi_shader_info info;
|
||||||
unsigned position_output;
|
unsigned position_output;
|
||||||
|
unsigned edgeflag_output;
|
||||||
|
|
||||||
/* Extracted from shader:
|
/* Extracted from shader:
|
||||||
*/
|
*/
|
||||||
|
@@ -238,8 +238,6 @@ softpipe_create( struct pipe_screen *screen )
|
|||||||
softpipe->pipe.draw_arrays = softpipe_draw_arrays;
|
softpipe->pipe.draw_arrays = softpipe_draw_arrays;
|
||||||
softpipe->pipe.draw_elements = softpipe_draw_elements;
|
softpipe->pipe.draw_elements = softpipe_draw_elements;
|
||||||
softpipe->pipe.draw_range_elements = softpipe_draw_range_elements;
|
softpipe->pipe.draw_range_elements = softpipe_draw_range_elements;
|
||||||
softpipe->pipe.set_edgeflags = softpipe_set_edgeflags;
|
|
||||||
|
|
||||||
|
|
||||||
softpipe->pipe.clear = softpipe_clear;
|
softpipe->pipe.clear = softpipe_clear;
|
||||||
softpipe->pipe.flush = softpipe_flush;
|
softpipe->pipe.flush = softpipe_flush;
|
||||||
|
@@ -184,11 +184,3 @@ softpipe_draw_elements(struct pipe_context *pipe,
|
|||||||
0, 0xffffffff,
|
0, 0xffffffff,
|
||||||
mode, start, count );
|
mode, start, count );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
softpipe_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags)
|
|
||||||
{
|
|
||||||
struct softpipe_context *sp = softpipe_context(pipe);
|
|
||||||
draw_set_edgeflags(sp->draw, edgeflags);
|
|
||||||
}
|
|
||||||
|
@@ -189,10 +189,6 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
|
|||||||
unsigned max_index,
|
unsigned max_index,
|
||||||
unsigned mode, unsigned start, unsigned count);
|
unsigned mode, unsigned start, unsigned count);
|
||||||
|
|
||||||
void
|
|
||||||
softpipe_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags);
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
softpipe_map_transfers(struct softpipe_context *sp);
|
softpipe_map_transfers(struct softpipe_context *sp);
|
||||||
|
|
||||||
|
@@ -113,8 +113,8 @@ find_translated_vp(struct st_context *st,
|
|||||||
* the input to the output. We'll need to use similar logic to set
|
* the input to the output. We'll need to use similar logic to set
|
||||||
* up the extra vertex_element input for edgeflags.
|
* up the extra vertex_element input for edgeflags.
|
||||||
*/
|
*/
|
||||||
key.passthrough_edgeflags = (ctx->Polygon.FrontMode != GL_FILL ||
|
key.passthrough_edgeflags = (st->ctx->Polygon.FrontMode != GL_FILL ||
|
||||||
ctx->Polygon.BackMode != GL_FILL);
|
st->ctx->Polygon.BackMode != GL_FILL);
|
||||||
|
|
||||||
|
|
||||||
/* Do we need to throw away old translations after a change in the
|
/* Do we need to throw away old translations after a change in the
|
||||||
|
@@ -738,11 +738,11 @@ emit_face_var( struct st_translate *t,
|
|||||||
*
|
*
|
||||||
* \return array of translated tokens, caller's responsibility to free
|
* \return array of translated tokens, caller's responsibility to free
|
||||||
*/
|
*/
|
||||||
const struct tgsi_token *
|
enum pipe_error
|
||||||
st_translate_mesa_program(
|
st_translate_mesa_program(
|
||||||
GLcontext *ctx,
|
GLcontext *ctx,
|
||||||
struct ureg_program *ureg;
|
|
||||||
uint procType,
|
uint procType,
|
||||||
|
struct ureg_program *ureg,
|
||||||
const struct gl_program *program,
|
const struct gl_program *program,
|
||||||
GLuint numInputs,
|
GLuint numInputs,
|
||||||
const GLuint inputMapping[],
|
const GLuint inputMapping[],
|
||||||
@@ -755,7 +755,6 @@ st_translate_mesa_program(
|
|||||||
const ubyte outputSemanticIndex[] )
|
const ubyte outputSemanticIndex[] )
|
||||||
{
|
{
|
||||||
struct st_translate translate, *t;
|
struct st_translate translate, *t;
|
||||||
const struct tgsi_token *tokens = NULL;
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
t = &translate;
|
t = &translate;
|
||||||
@@ -904,16 +903,15 @@ out:
|
|||||||
|
|
||||||
if (t->error) {
|
if (t->error) {
|
||||||
debug_printf("%s: translate error flag set\n", __FUNCTION__);
|
debug_printf("%s: translate error flag set\n", __FUNCTION__);
|
||||||
FREE((void *)tokens);
|
|
||||||
tokens = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ???
|
||||||
if (!tokens) {
|
if (!tokens) {
|
||||||
debug_printf("%s: failed to translate Mesa program:\n", __FUNCTION__);
|
debug_printf("%s: failed to translate Mesa program:\n", __FUNCTION__);
|
||||||
_mesa_print_program(program);
|
_mesa_print_program(program);
|
||||||
debug_assert(0);
|
debug_assert(0);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return PIPE_ERROR_OUT_OF_MEMORY;
|
return PIPE_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#define ST_MESA_TO_TGSI_H
|
#define ST_MESA_TO_TGSI_H
|
||||||
|
|
||||||
#include "main/mtypes.h"
|
#include "main/mtypes.h"
|
||||||
|
#include "tgsi/tgsi_ureg.h"
|
||||||
|
|
||||||
|
|
||||||
#if defined __cplusplus
|
#if defined __cplusplus
|
||||||
@@ -39,10 +40,11 @@ extern "C" {
|
|||||||
struct tgsi_token;
|
struct tgsi_token;
|
||||||
struct gl_program;
|
struct gl_program;
|
||||||
|
|
||||||
const struct tgsi_token *
|
enum pipe_error
|
||||||
st_translate_mesa_program(
|
st_translate_mesa_program(
|
||||||
GLcontext *ctx,
|
GLcontext *ctx,
|
||||||
uint procType,
|
uint procType,
|
||||||
|
struct ureg_program *ureg,
|
||||||
const struct gl_program *program,
|
const struct gl_program *program,
|
||||||
GLuint numInputs,
|
GLuint numInputs,
|
||||||
const GLuint inputMapping[],
|
const GLuint inputMapping[],
|
||||||
|
@@ -193,6 +193,7 @@ st_translate_vertex_program(struct st_context *st,
|
|||||||
struct st_vp_varient *vpv = CALLOC_STRUCT(st_vp_varient);
|
struct st_vp_varient *vpv = CALLOC_STRUCT(st_vp_varient);
|
||||||
struct pipe_context *pipe = st->pipe;
|
struct pipe_context *pipe = st->pipe;
|
||||||
struct ureg_program *ureg;
|
struct ureg_program *ureg;
|
||||||
|
enum pipe_error error;
|
||||||
|
|
||||||
ureg = ureg_create( TGSI_PROCESSOR_VERTEX );
|
ureg = ureg_create( TGSI_PROCESSOR_VERTEX );
|
||||||
if (ureg == NULL)
|
if (ureg == NULL)
|
||||||
@@ -215,18 +216,18 @@ st_translate_vertex_program(struct st_context *st,
|
|||||||
stvp->output_semantic_name,
|
stvp->output_semantic_name,
|
||||||
stvp->output_semantic_index );
|
stvp->output_semantic_index );
|
||||||
|
|
||||||
if (ret)
|
if (error)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* Edgeflags will be the last input:
|
/* Edgeflags will be the last input:
|
||||||
*/
|
*/
|
||||||
if (key.passthrough_edgeflags) {
|
if (key->passthrough_edgeflags) {
|
||||||
ureg_MOV( ureg,
|
ureg_MOV( ureg,
|
||||||
ureg_DECL_output( ureg, TGSI_SEMANTIC_EDGEFLAG, 0 ),
|
ureg_DECL_output( ureg, TGSI_SEMANTIC_EDGEFLAG, 0 ),
|
||||||
ureg_DECL_next_vs_input(ureg));
|
ureg_DECL_next_vs_input(ureg));
|
||||||
}
|
}
|
||||||
|
|
||||||
tokens = ureg_get_tokens( ureg, NULL );
|
vpv->state.tokens = ureg_get_tokens( ureg, NULL );
|
||||||
ureg_destroy( ureg );
|
ureg_destroy( ureg );
|
||||||
|
|
||||||
vpv->driver_shader = pipe->create_vs_state(pipe, &vpv->state);
|
vpv->driver_shader = pipe->create_vs_state(pipe, &vpv->state);
|
||||||
@@ -266,6 +267,7 @@ st_translate_fragment_program(struct st_context *st,
|
|||||||
GLuint defaultInputMapping[FRAG_ATTRIB_MAX];
|
GLuint defaultInputMapping[FRAG_ATTRIB_MAX];
|
||||||
GLuint interpMode[16]; /* XXX size? */
|
GLuint interpMode[16]; /* XXX size? */
|
||||||
GLuint attr;
|
GLuint attr;
|
||||||
|
enum pipe_error error;
|
||||||
const GLbitfield inputsRead = stfp->Base.Base.InputsRead;
|
const GLbitfield inputsRead = stfp->Base.Base.InputsRead;
|
||||||
struct ureg_program *ureg;
|
struct ureg_program *ureg;
|
||||||
GLuint vslot = 0;
|
GLuint vslot = 0;
|
||||||
@@ -404,12 +406,13 @@ st_translate_fragment_program(struct st_context *st,
|
|||||||
|
|
||||||
ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT );
|
ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT );
|
||||||
if (ureg == NULL)
|
if (ureg == NULL)
|
||||||
return NULL;
|
return;
|
||||||
|
|
||||||
|
|
||||||
stfp->state.tokens =
|
error =
|
||||||
st_translate_mesa_program(st->ctx,
|
st_translate_mesa_program(st->ctx,
|
||||||
TGSI_PROCESSOR_FRAGMENT,
|
TGSI_PROCESSOR_FRAGMENT,
|
||||||
|
ureg,
|
||||||
&stfp->Base.Base,
|
&stfp->Base.Base,
|
||||||
/* inputs */
|
/* inputs */
|
||||||
fs_num_inputs,
|
fs_num_inputs,
|
||||||
@@ -423,6 +426,8 @@ st_translate_fragment_program(struct st_context *st,
|
|||||||
fs_output_semantic_name,
|
fs_output_semantic_name,
|
||||||
fs_output_semantic_index );
|
fs_output_semantic_index );
|
||||||
|
|
||||||
|
stfp->state.tokens = ureg_get_tokens( ureg, NULL );
|
||||||
|
ureg_destroy( ureg );
|
||||||
stfp->driver_shader = pipe->create_fs_state(pipe, &stfp->state);
|
stfp->driver_shader = pipe->create_fs_state(pipe, &stfp->state);
|
||||||
|
|
||||||
if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
|
if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) {
|
||||||
|
Reference in New Issue
Block a user