[Mesa-dev] [PATCH 1/7] mesa: optionally associate a gl_program to ati_fragment_shader
Miklós Máté
mtmkls at gmail.com
Thu Feb 25 20:32:09 UTC 2016
On 02/25/2016 07:38 PM, Ian Romanick wrote:
> On 02/24/2016 05:37 PM, Brian Paul wrote:
>> On 02/24/2016 04:35 PM, Miklós Máté wrote:
>>> the state tracker will use it
>>>
>>> Signed-off-by: Miklós Máté <mtmkls at gmail.com>
>>> ---
>>> src/mesa/drivers/common/driverfuncs.c | 3 +++
>>> src/mesa/main/atifragshader.c | 13 ++++++++++++-
>>> src/mesa/main/dd.h | 7 ++++++-
>>> src/mesa/main/mtypes.h | 1 +
>>> src/mesa/main/state.c | 14 +++++++++++++-
>>> 5 files changed, 35 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/src/mesa/drivers/common/driverfuncs.c
>>> b/src/mesa/drivers/common/driverfuncs.c
>>> index 752aaf6..65a0cf8 100644
>>> --- a/src/mesa/drivers/common/driverfuncs.c
>>> +++ b/src/mesa/drivers/common/driverfuncs.c
>>> @@ -117,6 +117,9 @@ _mesa_init_driver_functions(struct
>>> dd_function_table *driver)
>>> driver->NewProgram = _mesa_new_program;
>>> driver->DeleteProgram = _mesa_delete_program;
>>>
>>> + /* ATI_fragment_shader */
>>> + driver->NewATIfs = NULL;
>>> +
>>> /* simple state commands */
>>> driver->AlphaFunc = NULL;
>>> driver->BlendColor = NULL;
>>> diff --git a/src/mesa/main/atifragshader.c
>>> b/src/mesa/main/atifragshader.c
>>> index 8fcbff6..34f45c6 100644
>>> --- a/src/mesa/main/atifragshader.c
>>> +++ b/src/mesa/main/atifragshader.c
>>> @@ -30,6 +30,7 @@
>>> #include "main/mtypes.h"
>>> #include "main/dispatch.h"
>>> #include "main/atifragshader.h"
>>> +#include "program/program.h"
>>>
>>> #define MESA_DEBUG_ATI_FS 0
>>>
>>> @@ -63,6 +64,7 @@ _mesa_delete_ati_fragment_shader(struct gl_context
>>> *ctx, struct ati_fragment_sha
>>> free(s->Instructions[i]);
>>> free(s->SetupInst[i]);
>>> }
>>> + _mesa_reference_program(ctx, &s->Program, NULL);
>>> free(s);
>>> }
>>>
>>> @@ -321,6 +323,8 @@ _mesa_BeginFragmentShaderATI(void)
>>> free(ctx->ATIFragmentShader.Current->SetupInst[i]);
>>> }
>>>
>>> + _mesa_reference_program(ctx,
>>> &ctx->ATIFragmentShader.Current->Program, NULL);
>>> +
>>> /* malloc the instructions here - not sure if the best place but its
>>> a start */
>>> for (i = 0; i < MAX_NUM_PASSES_ATI; i++) {
>>> @@ -405,7 +409,14 @@ _mesa_EndFragmentShaderATI(void)
>>> }
>>> #endif
>>>
>>> - if (!ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_SHADER_ATI,
>>> NULL)) {
>>> + if (ctx->Driver.NewATIfs) {
>>> + struct gl_program *prog = ctx->Driver.NewATIfs(ctx,
>>> +
>>> ctx->ATIFragmentShader.Current);
>>> + _mesa_reference_program(ctx,
>>> &ctx->ATIFragmentShader.Current->Program, prog);
>>> + }
>>> +
>>> + if (!ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_SHADER_ATI,
>>> + curProg->Program)) {
>>> ctx->ATIFragmentShader.Current->isValid = GL_FALSE;
>>> /* XXX is this the right error? */
>>> _mesa_error(ctx, GL_INVALID_OPERATION,
>>> diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
>>> index 3f5aa5d..8410a15 100644
>>> --- a/src/mesa/main/dd.h
>>> +++ b/src/mesa/main/dd.h
>>> @@ -473,7 +473,12 @@ struct dd_function_table {
>>> struct gl_program * (*NewProgram)(struct gl_context *ctx, GLenum
>>> target,
>>> GLuint id);
>>> /** Delete a program */
>>> - void (*DeleteProgram)(struct gl_context *ctx, struct gl_program
>>> *prog);
>>> + void (*DeleteProgram)(struct gl_context *ctx, struct gl_program
>>> *prog);
>>> + /**
>>> + * Allocate a program to associate with the new ATI fragment
>>> shader (optional)
>>> + */
>>> + struct gl_program * (*NewATIfs)(struct gl_context *ctx,
>>> + struct ati_fragment_shader *curProg);
>> The second line of the function decl should be indented more. See other
>> nearby functions for examples.
> Also... what changed in the DeleteProgram line? I've been staring at
> it, but I can't see the sailboat.
I accidentally included the removal of the trailing whitespace. My
editor automatically removes them, so I have to pick changes line-by-line.
>
>> Patch looks OK otherwise.
>>
>> Acked-by: Brian Paul <brianp at vmware.com>
> With the various whitespace issues fixed (and I think the DeleteProgram
> change is a whitespace issue of some sort), this patch is
>
> Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
>
> Miklós, I assume you need someone to commit this for you? I can fix the
> minor whitespace problems and commit it.
Yes, thank you. I thought I got rid of all formatting issues since the
last time, but it seems some of them eluded my attention.
MM
>
>>> /**
>>> * Notify driver that a program string (and GPU code) has been
>>> specified
>>> * or modified. Return GL_TRUE or GL_FALSE to indicate if the
>>> program is
>>> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
>>> index 12d3863..22e8a21 100644
>>> --- a/src/mesa/main/mtypes.h
>>> +++ b/src/mesa/main/mtypes.h
>>> @@ -2197,6 +2197,7 @@ struct ati_fragment_shader
>>> GLboolean interpinp1;
>>> GLboolean isValid;
>>> GLuint swizzlerq;
>>> + struct gl_program *Program;
>>> };
>>>
>>> /**
>>> diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
>>> index 57f1341..f4e8288 100644
>>> --- a/src/mesa/main/state.c
>>> +++ b/src/mesa/main/state.c
>>> @@ -124,7 +124,8 @@ update_program(struct gl_context *ctx)
>>> * follows:
>>> * 1. OpenGL 2.0/ARB vertex/fragment shaders
>>> * 2. ARB/NV vertex/fragment programs
>>> - * 3. Programs derived from fixed-function state.
>>> + * 3. ATI fragment shader
>>> + * 4. Programs derived from fixed-function state.
>>> *
>>> * Note: it's possible for a vertex shader to get used with a
>>> fragment
>>> * program (and vice versa) here, but in practice that shouldn't
>>> ever
>>> @@ -152,6 +153,17 @@ update_program(struct gl_context *ctx)
>>> _mesa_reference_fragprog(ctx,
>>> &ctx->FragmentProgram._TexEnvProgram,
>>> NULL);
>>> }
>>> + else if (ctx->ATIFragmentShader._Enabled &&
>>> + ctx->ATIFragmentShader.Current->Program) {
>>> + /* Use the enabled ATI fragment shader's associated program */
>>> + _mesa_reference_shader_program(ctx,
>>> +
>>> &ctx->_Shader->_CurrentFragmentProgram,
>>> + NULL);
>>> + _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
>>> +
>>> gl_fragment_program(ctx->ATIFragmentShader.Current->Program));
>>> + _mesa_reference_fragprog(ctx,
>>> &ctx->FragmentProgram._TexEnvProgram,
>>> + NULL);
>>> + }
>>> else if (ctx->FragmentProgram._MaintainTexEnvProgram) {
>>> /* Use fragment program generated from fixed-function state */
>>> struct gl_shader_program *f =
>>> _mesa_get_fixed_func_fragment_program(ctx);
>>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>
More information about the mesa-dev
mailing list