Maybe it's just me, since I actually wrote the docs, but does anybody else read them?
>From cso/rasterizer.html (viewable at e.g. http://people.freedesktop.org/~csimpson/gallium-docs/cso/rasterizer.html ): gl_rasterization_rules Whether the rasterizer should use (0.5, 0.5) pixel centers. When not set, the rasterizer will use (0, 0) for pixel centers. So why aren't these patches using pipe_rasterizer_state::gl_rasterization_rules? On Wed, Jan 20, 2010 at 10:38 PM, Luca Barbieri <l...@luca-barbieri.com> wrote: > This is totally untested and only a proof of concept. > > In particular, it may be necessary to add code to re-emit shader > constants on framebuffer height change. > --- > src/gallium/drivers/r300/r300_emit.c | 9 +++++++++ > src/gallium/drivers/r300/r300_fs.c | 2 ++ > src/gallium/drivers/r300/r300_fs.h | 2 ++ > src/gallium/drivers/r300/r300_screen.c | 3 +++ > src/gallium/drivers/r300/r300_tgsi_to_rc.c | 16 ++++++++++++++++ > src/gallium/drivers/r300/r300_tgsi_to_rc.h | 2 ++ > 6 files changed, 34 insertions(+), 0 deletions(-) > > diff --git a/src/gallium/drivers/r300/r300_emit.c > b/src/gallium/drivers/r300/r300_emit.c > index 11bd334..1f38033 100644 > --- a/src/gallium/drivers/r300/r300_emit.c > +++ b/src/gallium/drivers/r300/r300_emit.c > @@ -185,6 +185,8 @@ static const float * get_shader_constant( > vec[1] = viewport->yscale; > vec[2] = viewport->zscale; > } > + if(r300->fs->origin_lower_left) > + vec[1] = -vec[1]; > break; > > case RC_STATE_R300_VIEWPORT_OFFSET: > @@ -193,6 +195,13 @@ static const float * get_shader_constant( > vec[1] = viewport->yoffset; > vec[2] = viewport->zoffset; > } > + if(r300->fs->origin_lower_left) > + vec[1] = r300->framebuffer_state.height - vec[1]; > + if(r300->fs->pixel_center_integer) > + { > + vec[0] -= 0.5f; > + vec[1] -= 0.5f; > + } > break; > > default: > diff --git a/src/gallium/drivers/r300/r300_fs.c > b/src/gallium/drivers/r300/r300_fs.c > index 60ea9c1..4596205 100644 > --- a/src/gallium/drivers/r300/r300_fs.c > +++ b/src/gallium/drivers/r300/r300_fs.c > @@ -179,6 +179,8 @@ static void r300_translate_fragment_shader( > r300_tgsi_to_rc(&ttr, fs->state.tokens); > > fs->shadow_samplers = compiler.Base.Program.ShadowSamplers; > + fs->origin_lower_left = ttr.origin_lower_left; > + fs->pixel_center_integer = ttr.pixel_center_integer; > > /** > * Transform the program to support WPOS. > diff --git a/src/gallium/drivers/r300/r300_fs.h > b/src/gallium/drivers/r300/r300_fs.h > index 40ce874..542cf82 100644 > --- a/src/gallium/drivers/r300/r300_fs.h > +++ b/src/gallium/drivers/r300/r300_fs.h > @@ -46,6 +46,8 @@ struct r300_fragment_shader { > > /* Bits 0-15: TRUE if it's a shadow sampler, FALSE otherwise. */ > unsigned shadow_samplers; > + unsigned char origin_lower_left : 1; > + unsigned char pixel_center_integer : 1; > > /* Currently-bound fragment shader. */ > struct r300_fragment_shader_code* shader; > diff --git a/src/gallium/drivers/r300/r300_screen.c > b/src/gallium/drivers/r300/r300_screen.c > index 67325c6..82e95d5 100644 > --- a/src/gallium/drivers/r300/r300_screen.c > +++ b/src/gallium/drivers/r300/r300_screen.c > @@ -149,6 +149,9 @@ static int r300_get_param(struct pipe_screen* pscreen, > int param) > } else { > return 0; > } > + case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT: > + case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER: > + return 1; > default: > debug_printf("r300: Implementation error: Bad param %d\n", > param); > diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.c > b/src/gallium/drivers/r300/r300_tgsi_to_rc.c > index a792c2c..ad63458 100644 > --- a/src/gallium/drivers/r300/r300_tgsi_to_rc.c > +++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.c > @@ -277,6 +277,19 @@ static void transform_instruction(struct tgsi_to_rc * > ttr, struct tgsi_full_inst > &ttr->compiler->Program.ShadowSamplers); > } > > +static void handle_property(struct tgsi_to_rc * ttr, struct > tgsi_full_property * prop) > +{ > + switch(prop->Property.PropertyName) > + { > + case TGSI_PROPERTY_FS_COORD_ORIGIN: > + ttr->origin_lower_left = prop->u[0].Data; > + break; > + case TGSI_PROPERTY_FS_COORD_PIXEL_CENTER: > + ttr->pixel_center_integer = prop->u[0].Data; > + break; > + } > +} > + > static void handle_immediate(struct tgsi_to_rc * ttr, struct > tgsi_full_immediate * imm) > { > struct rc_constant constant; > @@ -314,6 +327,9 @@ void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const > struct tgsi_token * tokens) > tgsi_parse_token(&parser); > > switch (parser.FullToken.Token.Type) { > + case TGSI_TOKEN_TYPE_PROPERTY: > + handle_property(ttr, &parser.FullToken.FullProperty); > + break; > case TGSI_TOKEN_TYPE_DECLARATION: > break; > case TGSI_TOKEN_TYPE_IMMEDIATE: > diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.h > b/src/gallium/drivers/r300/r300_tgsi_to_rc.h > index 93e90ec..392239c 100644 > --- a/src/gallium/drivers/r300/r300_tgsi_to_rc.h > +++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.h > @@ -34,6 +34,8 @@ struct tgsi_to_rc { > const struct tgsi_shader_info * info; > > int immediate_offset; > + unsigned char origin_lower_left : 1; > + unsigned char pixel_center_integer : 1; > }; > > void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * > tokens); > -- > 1.6.3.3 > > > ------------------------------------------------------------------------------ > Throughout its 18-year history, RSA Conference consistently attracts the > world's best and brightest in the field, creating opportunities for Conference > attendees to learn about information security's most important issues through > interactions with peers, luminaries and emerging and established companies. > http://p.sf.net/sfu/rsaconf-dev2dev > _______________________________________________ > Mesa3d-dev mailing list > Mesa3d-dev@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mesa3d-dev > -- Only fools are easily impressed by what is only barely beyond their reach. ~ Unknown Corbin Simpson <mostawesomed...@gmail.com> ------------------------------------------------------------------------------ Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev _______________________________________________ Mesa3d-dev mailing list Mesa3d-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mesa3d-dev