[Mesa-dev] [PATCH] gallium: pass in per-sample interpolation qualifier
Roland Scheidegger
sroland at vmware.com
Thu Jul 3 08:28:51 PDT 2014
Am 03.07.2014 03:19, schrieb Ilia Mirkin:
> On Wed, Jul 2, 2014 at 4:03 PM, Roland Scheidegger <sroland at vmware.com> wrote:
>> Actually on second thought, because centroid and sample are mutually
>> exclusive (or more generally, the "Interpolate" member determines "how"
>> interpolation is done, whereas these two determine the "where")
>> something like this might be better:
>>
>> struct tgsi_declaration_interp
>> {
>> unsigned Interpolate : 4; /**< one of TGSI_INTERPOLATE_x */
>> unsigned Location : 2; /**< one of TGSI_INTERPOLATE_LOC_x */
>> unsigned CylindricalWrap:4; /**< TGSI_CYLINDRICAL_WRAP_x flags */
>> unsigned Padding : 22;
>> };
>>
>> TGSI_INTERPOLATE_LOC_CENTER 0
>> TGSI_INTERPOLATE_LOC_CENTROID 1
>> TGSI_INTERPOLATE_LOC_SAMPLE 2
>>
>> Or something like that. Not sure though...
>
> Yeah, that was the alternative I was mentioning of "combining" it with
> Centroid. Happy to do it either way. Obviously this would cause a lot
> more driver updates, but I don't mind -- I suspect the uses of
> Centroid are fairly few, probably 1-2 per driver.
>
> Let me know what you prefer.
I think this would be cleaner. But I could live with the other solution
if others prefer that. You'd just have to mention somewhere in the docs
that combination of sample/centroid is invalid (or otherwise say which
takes precedence though I don't think that would make sense).
Roland
> -ilia
>
>>
>> Roland
>>
>>
>>
>> Am 02.07.2014 19:04, schrieb Roland Scheidegger:
>>> I don't have much of an idea how the interaction with per sample shading
>>> should look like, but this looks alright to me.
>>>
>>> Roland
>>>
>>> Am 02.07.2014 03:55, schrieb Ilia Mirkin:
>>>> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
>>>> ---
>>>>
>>>> Not sure if this is the right approach or if I should combine it with Centroid
>>>> more directly. More modifications will be required wrt per-sample shading
>>>> since we'll need to distinguish the min samples case where everything is
>>>> per-sample-interpolated vs this case where only some inputs are to be
>>>> sample-interpolated but the min samples would still be > 1. (Perhaps that case
>>>> should be handled by instead manually annotating each input as
>>>> per-sample-interpolated and sticking the overall per-sample-shading into a
>>>> variant key. This is roughly what i965 does.)
>>>>
>>>> But I thought I'd send this out to get some early feedback.
>>>>
>>>> src/gallium/auxiliary/tgsi/tgsi_dump.c | 4 ++++
>>>> src/gallium/auxiliary/tgsi/tgsi_ureg.c | 12 +++++++++---
>>>> src/gallium/auxiliary/tgsi/tgsi_ureg.h | 7 ++++---
>>>> src/gallium/include/pipe/p_shader_tokens.h | 3 ++-
>>>> src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 6 +++++-
>>>> src/mesa/state_tracker/st_glsl_to_tgsi.h | 1 +
>>>> src/mesa/state_tracker/st_program.c | 5 +++++
>>>> 7 files changed, 30 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
>>>> index 8e09bac..cce7858 100644
>>>> --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
>>>> +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
>>>> @@ -353,6 +353,10 @@ iter_declaration(
>>>> TXT( ", CENTROID" );
>>>> }
>>>>
>>>> + if (decl->Interp.Sample) {
>>>> + TXT( ", SAMPLE" );
>>>> + }
>>>> +
>>>> if (decl->Interp.CylindricalWrap) {
>>>> TXT(", CYLWRAP_");
>>>> if (decl->Interp.CylindricalWrap & TGSI_CYLINDRICAL_WRAP_X) {
>>>> diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
>>>> index bd0a3f7..b21339e 100644
>>>> --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
>>>> +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
>>>> @@ -104,6 +104,7 @@ struct ureg_program
>>>> unsigned interp;
>>>> unsigned char cylindrical_wrap;
>>>> unsigned char centroid;
>>>> + unsigned char sample;
>>>> } fs_input[UREG_MAX_INPUT];
>>>> unsigned nr_fs_inputs;
>>>>
>>>> @@ -345,7 +346,8 @@ ureg_DECL_fs_input_cyl_centroid(struct ureg_program *ureg,
>>>> unsigned semantic_index,
>>>> unsigned interp_mode,
>>>> unsigned cylindrical_wrap,
>>>> - unsigned centroid)
>>>> + unsigned centroid,
>>>> + unsigned sample)
>>>> {
>>>> unsigned i;
>>>>
>>>> @@ -362,6 +364,7 @@ ureg_DECL_fs_input_cyl_centroid(struct ureg_program *ureg,
>>>> ureg->fs_input[i].interp = interp_mode;
>>>> ureg->fs_input[i].cylindrical_wrap = cylindrical_wrap;
>>>> ureg->fs_input[i].centroid = centroid;
>>>> + ureg->fs_input[i].sample = sample;
>>>> ureg->nr_fs_inputs++;
>>>> } else {
>>>> set_bad(ureg);
>>>> @@ -1288,7 +1291,8 @@ emit_decl_fs(struct ureg_program *ureg,
>>>> unsigned semantic_index,
>>>> unsigned interpolate,
>>>> unsigned cylindrical_wrap,
>>>> - unsigned centroid)
>>>> + unsigned centroid,
>>>> + unsigned sample)
>>>> {
>>>> union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 4);
>>>>
>>>> @@ -1308,6 +1312,7 @@ emit_decl_fs(struct ureg_program *ureg,
>>>> out[2].decl_interp.Interpolate = interpolate;
>>>> out[2].decl_interp.CylindricalWrap = cylindrical_wrap;
>>>> out[2].decl_interp.Centroid = centroid;
>>>> + out[2].decl_interp.Sample = sample;
>>>>
>>>> out[3].value = 0;
>>>> out[3].decl_semantic.Name = semantic_name;
>>>> @@ -1539,7 +1544,8 @@ static void emit_decls( struct ureg_program *ureg )
>>>> ureg->fs_input[i].semantic_index,
>>>> ureg->fs_input[i].interp,
>>>> ureg->fs_input[i].cylindrical_wrap,
>>>> - ureg->fs_input[i].centroid);
>>>> + ureg->fs_input[i].centroid,
>>>> + ureg->fs_input[i].sample);
>>>> }
>>>> } else {
>>>> for (i = 0; i < ureg->nr_gs_inputs; i++) {
>>>> diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
>>>> index 28edea6..d1f37e0 100644
>>>> --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
>>>> +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
>>>> @@ -199,7 +199,8 @@ ureg_DECL_fs_input_cyl_centroid(struct ureg_program *,
>>>> unsigned semantic_index,
>>>> unsigned interp_mode,
>>>> unsigned cylindrical_wrap,
>>>> - unsigned centroid);
>>>> + unsigned centroid,
>>>> + unsigned sample);
>>>>
>>>> static INLINE struct ureg_src
>>>> ureg_DECL_fs_input_cyl(struct ureg_program *ureg,
>>>> @@ -213,7 +214,7 @@ ureg_DECL_fs_input_cyl(struct ureg_program *ureg,
>>>> semantic_index,
>>>> interp_mode,
>>>> cylindrical_wrap,
>>>> - 0);
>>>> + 0, 0);
>>>> }
>>>>
>>>> static INLINE struct ureg_src
>>>> @@ -226,7 +227,7 @@ ureg_DECL_fs_input(struct ureg_program *ureg,
>>>> semantic_name,
>>>> semantic_index,
>>>> interp_mode,
>>>> - 0, 0);
>>>> + 0, 0, 0);
>>>> }
>>>>
>>>> struct ureg_src
>>>> diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
>>>> index 9261b79..bb3320c 100644
>>>> --- a/src/gallium/include/pipe/p_shader_tokens.h
>>>> +++ b/src/gallium/include/pipe/p_shader_tokens.h
>>>> @@ -139,8 +139,9 @@ struct tgsi_declaration_interp
>>>> {
>>>> unsigned Interpolate : 4; /**< one of TGSI_INTERPOLATE_x */
>>>> unsigned Centroid : 1; /**< centroid sampling? */
>>>> + unsigned Sample : 1; /**< per-sample interpolation? */
>>>> unsigned CylindricalWrap:4; /**< TGSI_CYLINDRICAL_WRAP_x flags */
>>>> - unsigned Padding : 23;
>>>> + unsigned Padding : 22;
>>>> };
>>>>
>>>> #define TGSI_SEMANTIC_POSITION 0
>>>> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>>>> index 9e19431..1174a69 100644
>>>> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>>>> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>>>> @@ -4848,6 +4848,8 @@ emit_edgeflags(struct st_translate *t)
>>>> * \param inputSemanticIndex the semantic index (ex: which texcoord) for
>>>> * each input
>>>> * \param interpMode the TGSI_INTERPOLATE_LINEAR/PERSP mode for each input
>>>> + * \param is_centroid whether the input should have centroid interpolation
>>>> + * \param is_sample whether the input should have sample interpolation
>>>> * \param numOutputs number of output registers used
>>>> * \param outputMapping maps Mesa fragment program outputs to TGSI
>>>> * generic outputs
>>>> @@ -4870,6 +4872,7 @@ st_translate_program(
>>>> const ubyte inputSemanticIndex[],
>>>> const GLuint interpMode[],
>>>> const GLboolean is_centroid[],
>>>> + const GLboolean is_sample[],
>>>> GLuint numOutputs,
>>>> const GLuint outputMapping[],
>>>> const ubyte outputSemanticName[],
>>>> @@ -4915,7 +4918,8 @@ st_translate_program(
>>>> inputSemanticName[i],
>>>> inputSemanticIndex[i],
>>>> interpMode[i], 0,
>>>> - is_centroid[i]);
>>>> + is_centroid[i],
>>>> + is_sample[i]);
>>>> }
>>>>
>>>> if (proginfo->InputsRead & VARYING_BIT_POS) {
>>>> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.h b/src/mesa/state_tracker/st_glsl_to_tgsi.h
>>>> index a3fe91f..ff93d0b 100644
>>>> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.h
>>>> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.h
>>>> @@ -46,6 +46,7 @@ enum pipe_error st_translate_program(
>>>> const ubyte inputSemanticIndex[],
>>>> const GLuint interpMode[],
>>>> const GLboolean is_centroid[],
>>>> + const GLboolean is_sample[],
>>>> GLuint numOutputs,
>>>> const GLuint outputMapping[],
>>>> const ubyte outputSemanticName[],
>>>> diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
>>>> index 1df411c..e2b54d2 100644
>>>> --- a/src/mesa/state_tracker/st_program.c
>>>> +++ b/src/mesa/state_tracker/st_program.c
>>>> @@ -348,6 +348,7 @@ st_translate_vertex_program(struct st_context *st,
>>>> NULL, /* input semantic index */
>>>> NULL, /* interp mode */
>>>> NULL, /* is centroid */
>>>> + NULL, /* is sample */
>>>> /* outputs */
>>>> num_outputs,
>>>> stvp->result_to_output,
>>>> @@ -486,6 +487,7 @@ st_translate_fragment_program(struct st_context *st,
>>>> ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS];
>>>> ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
>>>> GLboolean is_centroid[PIPE_MAX_SHADER_INPUTS];
>>>> + GLboolean is_sample[PIPE_MAX_SHADER_INPUTS];
>>>> uint fs_num_inputs = 0;
>>>>
>>>> ubyte fs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];
>>>> @@ -538,6 +540,7 @@ st_translate_fragment_program(struct st_context *st,
>>>>
>>>> inputMapping[attr] = slot;
>>>> is_centroid[slot] = (stfp->Base.IsCentroid & BITFIELD64_BIT(attr)) != 0;
>>>> + is_sample[slot] = (stfp->Base.IsSample & BITFIELD64_BIT(attr)) != 0;
>>>>
>>>> switch (attr) {
>>>> case VARYING_SLOT_POS:
>>>> @@ -765,6 +768,7 @@ st_translate_fragment_program(struct st_context *st,
>>>> input_semantic_index,
>>>> interpMode,
>>>> is_centroid,
>>>> + is_sample,
>>>> /* outputs */
>>>> fs_num_outputs,
>>>> outputMapping,
>>>> @@ -1125,6 +1129,7 @@ st_translate_geometry_program(struct st_context *st,
>>>> stgp->input_semantic_index,
>>>> NULL,
>>>> NULL,
>>>> + NULL,
>>>> /* outputs */
>>>> gs_num_outputs,
>>>> outputMapping,
>>>>
>>> _______________________________________________
>>> mesa-dev mailing list
>>> mesa-dev at lists.freedesktop.org
>>> https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=F4msKE2WxRzA%2BwN%2B25muztFm5TSPwE8HKJfWfR2NgfY%3D%0A&m=UfYfiCK7WxAP9fFMo5C9CPgze162fB7BfmyywvZh9wM%3D%0A&s=aa034a9488499d071eb7c733c0fabf41371e9557d27b3bcec8b9aa9a8a0c9727
>>>
More information about the mesa-dev
mailing list