[Mesa-dev] [PATCH] mesa: use _mesa_shader_stage_to_string() to generate file extension

Emil Velikov emil.l.velikov at gmail.com
Sun Jan 19 16:38:39 PST 2014


On 20/01/14 00:27, Chris Forbes wrote:
> What do you plan on using for `tesselation control` and `tesselation
> evaluation` shaders?
> 
Ouch very nice argument. I only had vertex, fragment and compute shaders
in mind.

Please ignore my rumbling.
-Emil

> On Mon, Jan 20, 2014 at 12:56 PM, Emil Velikov <emil.l.velikov at gmail.com> wrote:
>> ping ?
>>
>> On 10/01/14 18:44, Emil Velikov wrote:
>>> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
>>> ---
>>>
>>> Hi Paul,
>>>
>>> Here is another small cleanup inspired by your work. Not
>>> entirely sure that the last hunk is correct though.
>>>
>>> Cheers,
>>> Emil
>>>
>>> ---
>>>  src/mesa/program/prog_print.c | 26 +++++---------------------
>>>  1 file changed, 5 insertions(+), 21 deletions(-)
>>>
>>> diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c
>>> index 9391e99..4962401 100644
>>> --- a/src/mesa/program/prog_print.c
>>> +++ b/src/mesa/program/prog_print.c
>>> @@ -31,6 +31,7 @@
>>>
>>>  #include <inttypes.h>  /* for PRIx64 macro */
>>>
>>> +#include "glsl_parser_extras.h"
>>>  #include "main/glheader.h"
>>>  #include "main/context.h"
>>>  #include "main/imports.h"
>>> @@ -1005,23 +1006,11 @@ _mesa_print_parameter_list(const struct gl_program_parameter_list *list)
>>>  void
>>>  _mesa_write_shader_to_file(const struct gl_shader *shader)
>>>  {
>>> -   const char *type = "????";
>>>     char filename[100];
>>>     FILE *f;
>>>
>>> -   switch (shader->Stage) {
>>> -   case MESA_SHADER_FRAGMENT:
>>> -      type = "frag";
>>> -      break;
>>> -   case MESA_SHADER_VERTEX:
>>> -      type = "vert";
>>> -      break;
>>> -   case MESA_SHADER_GEOMETRY:
>>> -      type = "geom";
>>> -      break;
>>> -   }
>>> -
>>> -   _mesa_snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type);
>>> +   _mesa_snprintf(filename, sizeof(filename), "shader_%u.%.4s", shader->Name,
>>> +                  _mesa_shader_stage_to_string(shader->Stage));
>>>     f = fopen(filename, "w");
>>>     if (!f) {
>>>        fprintf(stderr, "Unable to open %s for writing\n", filename);
>>> @@ -1062,16 +1051,11 @@ void
>>>  _mesa_append_uniforms_to_file(const struct gl_shader *shader)
>>>  {
>>>     const struct gl_program *const prog = shader->Program;
>>> -   const char *type;
>>>     char filename[100];
>>>     FILE *f;
>>>
>>> -   if (shader->Stage == MESA_SHADER_FRAGMENT)
>>> -      type = "frag";
>>> -   else
>>> -      type = "vert";
>>> -
>>> -   _mesa_snprintf(filename, sizeof(filename), "shader_%u.%s", shader->Name, type);
>>> +   _mesa_snprintf(filename, sizeof(filename), "shader_%u.%.4s", shader->Name,
>>> +                  _mesa_shader_stage_to_string(shader->Stage));
>>>     f = fopen(filename, "a"); /* append */
>>>     if (!f) {
>>>        fprintf(stderr, "Unable to open %s for appending\n", filename);
>>>
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev



More information about the mesa-dev mailing list