[Mesa-dev] [PATCH 1/2] st/mesa: simplify shader limit initialization code
Brian Paul
brianp at vmware.com
Fri Jan 10 15:07:11 PST 2014
On 01/10/2014 03:50 PM, Marek Olšák wrote:
> On Thu, Jan 9, 2014 at 8:21 PM, Brian Paul <brianp at vmware.com> wrote:
>> Make use of the new gl_constants::Program[] array.
>> ---
>> src/mesa/state_tracker/st_extensions.c | 31 ++++++++--------------------
>> src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 20 +-----------------
>> src/mesa/state_tracker/st_program.h | 18 ++++++++++++++++
>> 3 files changed, 28 insertions(+), 41 deletions(-)
>>
>> diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
>> index c17601a..cc63b36 100644
>> --- a/src/mesa/state_tracker/st_extensions.c
>> +++ b/src/mesa/state_tracker/st_extensions.c
>> @@ -38,6 +38,8 @@
>> #include "st_context.h"
>> #include "st_extensions.h"
>> #include "st_format.h"
>> +#include "st_program.h"
>> +
>>
>> static unsigned _min(unsigned a, unsigned b)
>> {
>> @@ -68,8 +70,8 @@ void st_init_limits(struct st_context *st)
>> {
>> struct pipe_screen *screen = st->pipe->screen;
>> struct gl_constants *c = &st->ctx->Const;
>> - unsigned sh;
>> boolean can_ubo = TRUE;
>> + int i;
>>
>> c->MaxTextureLevels
>> = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS),
>> @@ -149,27 +151,12 @@ void st_init_limits(struct st_context *st)
>> can_ubo = FALSE;
>> }
>>
>> - for (sh = 0; sh < PIPE_SHADER_TYPES; ++sh) {
>> - struct gl_shader_compiler_options *options;
>> - struct gl_program_constants *pc;
>> -
>> - switch (sh) {
>> - case PIPE_SHADER_FRAGMENT:
>> - pc = &c->Program[MESA_SHADER_FRAGMENT];
>> - options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_FRAGMENT];
>> - break;
>> - case PIPE_SHADER_VERTEX:
>> - pc = &c->Program[MESA_SHADER_VERTEX];
>> - options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX];
>> - break;
>> - case PIPE_SHADER_GEOMETRY:
>> - pc = &c->Program[MESA_SHADER_GEOMETRY];
>> - options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_GEOMETRY];
>> - break;
>> - default:
>> - /* compute shader, etc. */
>> - continue;
>> - }
>> + /* Note: we only loop over the currently supported gallium shader types */
>> + for (i = MESA_SHADER_VERTEX; i <= MESA_SHADER_FRAGMENT; i++) {
>
> The MESA_SHADER_xxx numbers are ordered in the same way they appear in
> the pipeline, so tessellation shaders will be before
> MESA_SHADER_FRAGMENT. In other words, the comment in the code is not
> true and st_shader_stage_to_ptarget should be more robust to handle
> unsupported shader types.
Ah, I was thinking tessellation shaders came before the vertex shader,
but they don't. I'll respin this someday.
-Brian
More information about the mesa-dev
mailing list