[Mesa-dev] [PATCH 09/20] mesa: add inline conversion functions for ARB_shader_subroutine
Ilia Mirkin
imirkin at alum.mit.edu
Mon Jul 20 22:25:52 PDT 2015
On Tue, Jul 21, 2015 at 1:19 AM, Dave Airlie <airlied at gmail.com> wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> This handles converting the shader stages to the internal
> prefix along with the program resource interfaces.
>
> Reviewed-by: Chris Forbes <chrisf at ijw.co.nz>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
> src/mesa/main/shaderobj.h | 84 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 84 insertions(+)
>
> diff --git a/src/mesa/main/shaderobj.h b/src/mesa/main/shaderobj.h
> index 3d696a1..67c717b 100644
> --- a/src/mesa/main/shaderobj.h
> +++ b/src/mesa/main/shaderobj.h
> @@ -120,6 +120,90 @@ _mesa_shader_enum_to_shader_stage(GLenum v)
> }
>
>
> +static inline const char *
> +_mesa_shader_stage_to_subroutine_prefix(gl_shader_stage stage)
> +{
> + switch (stage) {
> + case MESA_SHADER_VERTEX:
> + return "__subu_v";
> + case MESA_SHADER_GEOMETRY:
> + return "__subu_g";
> + case MESA_SHADER_FRAGMENT:
> + return "__subu_f";
> + case MESA_SHADER_COMPUTE:
> + return "__subu_c";
> + default:
> + return NULL;
> + }
> +}
> +
> +static inline gl_shader_stage
> +_mesa_shader_stage_from_subroutine_uniform(GLenum subuniform)
> +{
> + switch (subuniform) {
> + default:
> + case GL_VERTEX_SUBROUTINE_UNIFORM:
> + return MESA_SHADER_VERTEX;
> + case GL_GEOMETRY_SUBROUTINE_UNIFORM:
> + return MESA_SHADER_GEOMETRY;
> + case GL_FRAGMENT_SUBROUTINE_UNIFORM:
> + return MESA_SHADER_FRAGMENT;
> + case GL_COMPUTE_SUBROUTINE_UNIFORM:
> + return MESA_SHADER_COMPUTE;
> + /* TODO - COMPUTE, TESS */
Compute seems to be done already...
> + }
> +}
> +
> +static inline gl_shader_stage
> +_mesa_shader_stage_from_subroutine(GLenum subroutine)
> +{
> + switch (subroutine) {
> + case GL_VERTEX_SUBROUTINE:
> + return MESA_SHADER_VERTEX;
> + case GL_GEOMETRY_SUBROUTINE:
> + return MESA_SHADER_GEOMETRY;
> + case GL_FRAGMENT_SUBROUTINE:
> + return MESA_SHADER_FRAGMENT;
> + case GL_COMPUTE_SUBROUTINE:
> + return MESA_SHADER_COMPUTE;
> + /* TODO - TESS */
> + }
> +}
> +
> +static inline GLenum
> +_mesa_shader_stage_to_subroutine(gl_shader_stage stage)
> +{
> + switch (stage) {
> + default:
> + case MESA_SHADER_VERTEX:
> + return GL_VERTEX_SUBROUTINE;
> + case MESA_SHADER_GEOMETRY:
> + return GL_GEOMETRY_SUBROUTINE;
> + case MESA_SHADER_FRAGMENT:
> + return GL_FRAGMENT_SUBROUTINE;
> + case MESA_SHADER_COMPUTE:
> + return GL_COMPUTE_SUBROUTINE;
> + /* TODO - TESS */
> + }
> +}
> +
> +static inline GLenum
> +_mesa_shader_stage_to_subroutine_uniform(gl_shader_stage stage)
> +{
> + switch (stage) {
> + default:
> + case MESA_SHADER_VERTEX:
> + return GL_VERTEX_SUBROUTINE_UNIFORM;
> + case MESA_SHADER_GEOMETRY:
> + return GL_GEOMETRY_SUBROUTINE_UNIFORM;
> + case MESA_SHADER_FRAGMENT:
> + return GL_FRAGMENT_SUBROUTINE_UNIFORM;
> + case MESA_SHADER_COMPUTE:
> + return GL_COMPUTE_SUBROUTINE_UNIFORM;
> + /* TODO - TESS */
> + }
> +}
> +
> #ifdef __cplusplus
> }
> #endif
> --
> 2.4.3
>
> _______________________________________________
> 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