[Mesa-dev] [PATCH] swr: autogenerate swr_context_llvm.h

Ilia Mirkin imirkin at alum.mit.edu
Tue Apr 26 16:57:14 UTC 2016


Could I put in a good word for adding it to .gitignore as well?

On Tue, Apr 26, 2016 at 12:55 PM, Tim Rowley <timothy.o.rowley at intel.com> wrote:
> ---
>  src/gallium/drivers/swr/Makefile.am                |   7 ++
>  src/gallium/drivers/swr/Makefile.sources           |   1 -
>  .../rasterizer/jitter/scripts/gen_llvm_types.py    |   3 +
>  src/gallium/drivers/swr/swr_context.h              |   8 +-
>  src/gallium/drivers/swr/swr_context_llvm.h         | 124 ---------------------
>  5 files changed, 15 insertions(+), 128 deletions(-)
>  delete mode 100644 src/gallium/drivers/swr/swr_context_llvm.h
>
> diff --git a/src/gallium/drivers/swr/Makefile.am b/src/gallium/drivers/swr/Makefile.am
> index b1ff423..6915aae 100644
> --- a/src/gallium/drivers/swr/Makefile.am
> +++ b/src/gallium/drivers/swr/Makefile.am
> @@ -47,6 +47,7 @@ COMMON_SOURCES = \
>         $(BUILT_SOURCES)
>
>  BUILT_SOURCES = \
> +       swr_context_llvm.h \
>         rasterizer/scripts/gen_knobs.cpp \
>         rasterizer/scripts/gen_knobs.h \
>         rasterizer/jitter/state_llvm.h \
> @@ -55,6 +56,12 @@ BUILT_SOURCES = \
>         rasterizer/jitter/builder_x86.h \
>         rasterizer/jitter/builder_x86.cpp
>
> +swr_context_llvm.h: rasterizer/jitter/scripts/gen_llvm_types.py swr_context.h
> +       $(PYTHON2) $(PYTHON_FLAGS) \
> +               $(srcdir)/rasterizer/jitter/scripts/gen_llvm_types.py \
> +               --input $(srcdir)/swr_context.h \
> +               --output swr_context_llvm.h
> +
>  rasterizer/scripts/gen_knobs.cpp rasterizer/scripts/gen_knobs.h: rasterizer/scripts/gen_knobs.py rasterizer/scripts/knob_defs.py rasterizer/scripts/templates/knobs.template
>         $(PYTHON2) $(PYTHON_FLAGS) \
>                 $(srcdir)/rasterizer/scripts/gen_knobs.py \
> diff --git a/src/gallium/drivers/swr/Makefile.sources b/src/gallium/drivers/swr/Makefile.sources
> index be3d8f0..d8be0f5 100644
> --- a/src/gallium/drivers/swr/Makefile.sources
> +++ b/src/gallium/drivers/swr/Makefile.sources
> @@ -26,7 +26,6 @@ CXX_SOURCES := \
>         swr_clear.cpp \
>         swr_context.cpp \
>         swr_context.h \
> -       swr_context_llvm.h \
>         swr_draw.cpp \
>         swr_public.h \
>         swr_resource.h \
> diff --git a/src/gallium/drivers/swr/rasterizer/jitter/scripts/gen_llvm_types.py b/src/gallium/drivers/swr/rasterizer/jitter/scripts/gen_llvm_types.py
> index 0b53a92..d6babd3 100644
> --- a/src/gallium/drivers/swr/rasterizer/jitter/scripts/gen_llvm_types.py
> +++ b/src/gallium/drivers/swr/rasterizer/jitter/scripts/gen_llvm_types.py
> @@ -135,6 +135,9 @@ def gen_llvm_types(input_file, output_file):
>      for idx in range(len(lines)):
>          line = lines[idx].rstrip()
>
> +        if "gen_llvm_types FINI" in line:
> +            break
> +
>          match = re.match(r"(\s*)struct(\s*)(\w+)", line)
>          if match:
>              llvm_args = []
> diff --git a/src/gallium/drivers/swr/swr_context.h b/src/gallium/drivers/swr/swr_context.h
> index 73a8e8d..a7383bb 100644
> --- a/src/gallium/drivers/swr/swr_context.h
> +++ b/src/gallium/drivers/swr/swr_context.h
> @@ -65,7 +65,7 @@ struct swr_jit_texture {
>     uint32_t depth; // doubles as array size
>     uint32_t first_level;
>     uint32_t last_level;
> -   const void *base_ptr;
> +   const uint8_t *base_ptr;
>     uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS];
>     uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS];
>     uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS];
> @@ -80,9 +80,9 @@ struct swr_jit_sampler {
>
>  struct swr_draw_context {
>     const float *constantVS[PIPE_MAX_CONSTANT_BUFFERS];
> -   unsigned num_constantsVS[PIPE_MAX_CONSTANT_BUFFERS];
> +   uint32_t num_constantsVS[PIPE_MAX_CONSTANT_BUFFERS];
>     const float *constantFS[PIPE_MAX_CONSTANT_BUFFERS];
> -   unsigned num_constantsFS[PIPE_MAX_CONSTANT_BUFFERS];
> +   uint32_t num_constantsFS[PIPE_MAX_CONSTANT_BUFFERS];
>
>     swr_jit_texture texturesVS[PIPE_MAX_SHADER_SAMPLER_VIEWS];
>     swr_jit_sampler samplersVS[PIPE_MAX_SAMPLERS];
> @@ -92,6 +92,8 @@ struct swr_draw_context {
>     SWR_SURFACE_STATE renderTargets[SWR_NUM_ATTACHMENTS];
>  };
>
> +/* gen_llvm_types FINI */
> +
>  struct swr_context {
>     struct pipe_context pipe; /**< base class */
>
> diff --git a/src/gallium/drivers/swr/swr_context_llvm.h b/src/gallium/drivers/swr/swr_context_llvm.h
> deleted file mode 100644
> index 58da813..0000000
> --- a/src/gallium/drivers/swr/swr_context_llvm.h
> +++ /dev/null
> @@ -1,124 +0,0 @@
> -/****************************************************************************
> - * Copyright (C) 2015 Intel Corporation.   All Rights Reserved.
> - *
> - * Permission is hereby granted, free of charge, to any person obtaining a
> - * copy of this software and associated documentation files (the "Software"),
> - * to deal in the Software without restriction, including without limitation
> - * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> - * and/or sell copies of the Software, and to permit persons to whom the
> - * Software is furnished to do so, subject to the following conditions:
> - *
> - * The above copyright notice and this permission notice (including the next
> - * paragraph) shall be included in all copies or substantial portions of the
> - * Software.
> - *
> - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> - * IN THE SOFTWARE.
> - ***************************************************************************/
> -
> -#pragma once
> -
> -//////////////////////////////////////////////////////////////////////////
> -/// Generate LLVM type information for swr_jit_texture
> -INLINE static StructType *
> -Gen_swr_jit_texture(JitManager *pShG)
> -{
> -   LLVMContext &ctx = pShG->mContext;
> -   std::vector<Type *> members;
> -
> -   members.push_back(Type::getInt32Ty(ctx)); // width
> -   members.push_back(Type::getInt32Ty(ctx)); // height
> -   members.push_back(Type::getInt32Ty(ctx)); // depth
> -   members.push_back(Type::getInt32Ty(ctx)); // first_level
> -   members.push_back(Type::getInt32Ty(ctx)); // last_level
> -   members.push_back(PointerType::get(Type::getInt8Ty(ctx), 0)); // base_ptr
> -   members.push_back(ArrayType::get(Type::getInt32Ty(ctx),
> -                                    PIPE_MAX_TEXTURE_LEVELS)); // row_stride
> -   members.push_back(ArrayType::get(Type::getInt32Ty(ctx),
> -                                    PIPE_MAX_TEXTURE_LEVELS)); // img_stride
> -   members.push_back(ArrayType::get(Type::getInt32Ty(ctx),
> -                                    PIPE_MAX_TEXTURE_LEVELS)); // mip_offsets
> -
> -   return StructType::get(ctx, members, false);
> -}
> -
> -static const UINT swr_jit_texture_width = 0;
> -static const UINT swr_jit_texture_height = 1;
> -static const UINT swr_jit_texture_depth = 2;
> -static const UINT swr_jit_texture_first_level = 3;
> -static const UINT swr_jit_texture_last_level = 4;
> -static const UINT swr_jit_texture_base_ptr = 5;
> -static const UINT swr_jit_texture_row_stride = 6;
> -static const UINT swr_jit_texture_img_stride = 7;
> -static const UINT swr_jit_texture_mip_offsets = 8;
> -
> -//////////////////////////////////////////////////////////////////////////
> -/// Generate LLVM type information for swr_jit_sampler
> -INLINE static StructType *
> -Gen_swr_jit_sampler(JitManager *pShG)
> -{
> -   LLVMContext &ctx = pShG->mContext;
> -   std::vector<Type *> members;
> -
> -   members.push_back(Type::getFloatTy(ctx)); // min_lod
> -   members.push_back(Type::getFloatTy(ctx)); // max_lod
> -   members.push_back(Type::getFloatTy(ctx)); // lod_bias
> -   members.push_back(
> -      ArrayType::get(Type::getFloatTy(ctx), 4)); // border_color
> -
> -   return StructType::get(ctx, members, false);
> -}
> -
> -static const UINT swr_jit_sampler_min_lod = 0;
> -static const UINT swr_jit_sampler_max_lod = 1;
> -static const UINT swr_jit_sampler_lod_bias = 2;
> -static const UINT swr_jit_sampler_border_color = 3;
> -
> -//////////////////////////////////////////////////////////////////////////
> -/// Generate LLVM type information for swr_draw_context
> -INLINE static StructType *
> -Gen_swr_draw_context(JitManager *pShG)
> -{
> -   LLVMContext &ctx = pShG->mContext;
> -   std::vector<Type *> members;
> -
> -   members.push_back(
> -      ArrayType::get(PointerType::get(Type::getFloatTy(ctx), 0),
> -                     PIPE_MAX_CONSTANT_BUFFERS)); // constantVS
> -   members.push_back(ArrayType::get(
> -      Type::getInt32Ty(ctx), PIPE_MAX_CONSTANT_BUFFERS)); // num_constantsVS
> -   members.push_back(
> -      ArrayType::get(PointerType::get(Type::getFloatTy(ctx), 0),
> -                     PIPE_MAX_CONSTANT_BUFFERS)); // constantFS
> -   members.push_back(ArrayType::get(
> -      Type::getInt32Ty(ctx), PIPE_MAX_CONSTANT_BUFFERS)); // num_constantsFS
> -   members.push_back(
> -      ArrayType::get(Gen_swr_jit_texture(pShG),
> -                     PIPE_MAX_SHADER_SAMPLER_VIEWS)); // texturesVS
> -   members.push_back(ArrayType::get(Gen_swr_jit_sampler(pShG),
> -                                    PIPE_MAX_SAMPLERS)); // samplersVS
> -   members.push_back(
> -      ArrayType::get(Gen_swr_jit_texture(pShG),
> -                     PIPE_MAX_SHADER_SAMPLER_VIEWS)); // texturesFS
> -   members.push_back(ArrayType::get(Gen_swr_jit_sampler(pShG),
> -                                    PIPE_MAX_SAMPLERS)); // samplersFS
> -   members.push_back(ArrayType::get(Gen_SWR_SURFACE_STATE(pShG),
> -                                    SWR_NUM_ATTACHMENTS)); // renderTargets
> -
> -   return StructType::get(ctx, members, false);
> -}
> -
> -static const UINT swr_draw_context_constantVS = 0;
> -static const UINT swr_draw_context_num_constantsVS = 1;
> -static const UINT swr_draw_context_constantFS = 2;
> -static const UINT swr_draw_context_num_constantsFS = 3;
> -static const UINT swr_draw_context_texturesVS = 4;
> -static const UINT swr_draw_context_samplersVS = 5;
> -static const UINT swr_draw_context_texturesFS = 6;
> -static const UINT swr_draw_context_samplersFS = 7;
> -static const UINT swr_draw_context_renderTargets = 8;
> --
> 1.9.1
>
> _______________________________________________
> 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