revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / mesa / src / gallium / state_trackers / vega / shaders_cache.h
blob05014f25dccedb4669f319ab9df48d991fdfb943
1 /**************************************************************************
3 * Copyright 2009 VMware, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
15 * of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 **************************************************************************/
27 #ifndef SHADERS_CACHE_H
28 #define SHADERS_CACHE_H
31 struct vg_context;
32 struct pipe_context;
33 struct tgsi_token;
34 struct shaders_cache;
36 #define _SHADERS_PAINT_BITS 3
37 #define _SHADERS_IMAGE_BITS 2
38 #define _SHADERS_COLOR_TRANSFORM_BITS 1
39 #define _SHADERS_ALPHA_BITS 2
40 #define _SHADERS_BLEND_BITS 4
41 #define _SHADERS_MASK_BITS 1
42 #define _SHADERS_PREMULTIPLY_BITS 2
43 #define _SHADERS_BW_BITS 1
45 #define SHADERS_PAINT_SHIFT (0)
46 #define SHADERS_IMAGE_SHIFT (SHADERS_PAINT_SHIFT + _SHADERS_PAINT_BITS)
47 #define SHADERS_COLOR_TRANSFORM_SHIFT (SHADERS_IMAGE_SHIFT + _SHADERS_IMAGE_BITS)
48 #define SHADERS_ALPHA_SHIFT (SHADERS_COLOR_TRANSFORM_SHIFT + _SHADERS_COLOR_TRANSFORM_BITS)
49 #define SHADERS_BLEND_SHIFT (SHADERS_ALPHA_SHIFT + _SHADERS_ALPHA_BITS)
50 #define SHADERS_MASK_SHIFT (SHADERS_BLEND_SHIFT + _SHADERS_BLEND_BITS)
51 #define SHADERS_PREMULTIPLY_SHIFT (SHADERS_MASK_SHIFT + _SHADERS_MASK_BITS)
52 #define SHADERS_BW_SHIFT (SHADERS_PREMULTIPLY_SHIFT + _SHADERS_PREMULTIPLY_BITS)
54 #define _SHADERS_GET_STAGE(stage, id) \
55 ((id) & (((1 << _SHADERS_ ## stage ## _BITS) - 1) << SHADERS_ ## stage ## _SHIFT))
57 #define SHADERS_GET_PAINT_SHADER(id) _SHADERS_GET_STAGE(PAINT, id)
58 #define SHADERS_GET_IMAGE_SHADER(id) _SHADERS_GET_STAGE(IMAGE, id)
59 #define SHADERS_GET_COLOR_TRANSFORM_SHADER(id) _SHADERS_GET_STAGE(COLOR_TRANSFORM, id)
60 #define SHADERS_GET_ALPHA_SHADER(id) _SHADERS_GET_STAGE(ALPHA, id)
61 #define SHADERS_GET_BLEND_SHADER(id) _SHADERS_GET_STAGE(BLEND, id)
62 #define SHADERS_GET_MASK_SHADER(id) _SHADERS_GET_STAGE(MASK, id)
63 #define SHADERS_GET_PREMULTIPLY_SHADER(id) _SHADERS_GET_STAGE(PREMULTIPLY, id)
64 #define SHADERS_GET_BW_SHADER(id) _SHADERS_GET_STAGE(BW, id)
66 enum VegaShaderType {
67 VEGA_SOLID_FILL_SHADER = 1 << SHADERS_PAINT_SHIFT,
68 VEGA_LINEAR_GRADIENT_SHADER = 2 << SHADERS_PAINT_SHIFT,
69 VEGA_RADIAL_GRADIENT_SHADER = 3 << SHADERS_PAINT_SHIFT,
70 VEGA_PATTERN_SHADER = 4 << SHADERS_PAINT_SHIFT,
71 VEGA_PAINT_DEGENERATE_SHADER = 5 << SHADERS_PAINT_SHIFT,
73 VEGA_IMAGE_NORMAL_SHADER = 1 << SHADERS_IMAGE_SHIFT,
74 VEGA_IMAGE_MULTIPLY_SHADER = 2 << SHADERS_IMAGE_SHIFT,
75 VEGA_IMAGE_STENCIL_SHADER = 3 << SHADERS_IMAGE_SHIFT,
77 VEGA_COLOR_TRANSFORM_SHADER = 1 << SHADERS_COLOR_TRANSFORM_SHIFT,
79 VEGA_ALPHA_NORMAL_SHADER = 1 << SHADERS_ALPHA_SHIFT,
80 VEGA_ALPHA_PER_CHANNEL_SHADER = 2 << SHADERS_ALPHA_SHIFT,
82 VEGA_BLEND_SRC_SHADER = 1 << SHADERS_BLEND_SHIFT,
83 VEGA_BLEND_SRC_OVER_SHADER = 2 << SHADERS_BLEND_SHIFT,
84 VEGA_BLEND_DST_OVER_SHADER = 3 << SHADERS_BLEND_SHIFT,
85 VEGA_BLEND_SRC_IN_SHADER = 4 << SHADERS_BLEND_SHIFT,
86 VEGA_BLEND_DST_IN_SHADER = 5 << SHADERS_BLEND_SHIFT,
87 VEGA_BLEND_MULTIPLY_SHADER = 6 << SHADERS_BLEND_SHIFT,
88 VEGA_BLEND_SCREEN_SHADER = 7 << SHADERS_BLEND_SHIFT,
89 VEGA_BLEND_DARKEN_SHADER = 8 << SHADERS_BLEND_SHIFT,
90 VEGA_BLEND_LIGHTEN_SHADER = 9 << SHADERS_BLEND_SHIFT,
91 VEGA_BLEND_ADDITIVE_SHADER = 10<< SHADERS_BLEND_SHIFT,
93 VEGA_MASK_SHADER = 1 << SHADERS_MASK_SHIFT,
95 VEGA_PREMULTIPLY_SHADER = 1 << SHADERS_PREMULTIPLY_SHIFT,
96 VEGA_UNPREMULTIPLY_SHADER = 2 << SHADERS_PREMULTIPLY_SHIFT,
98 VEGA_BW_SHADER = 1 << SHADERS_BW_SHIFT
101 struct vg_shader {
102 void *driver;
103 struct tgsi_token *tokens;
104 int type;/* PIPE_SHADER_VERTEX, PIPE_SHADER_FRAGMENT */
107 struct shaders_cache *shaders_cache_create(struct vg_context *pipe);
108 void shaders_cache_destroy(struct shaders_cache *sc);
109 void *shaders_cache_fill(struct shaders_cache *sc,
110 int shader_key);
112 struct vg_shader *shader_create_from_text(struct pipe_context *pipe,
113 const char *txt, int num_tokens,
114 int type);
116 void vg_shader_destroy(struct vg_context *ctx, struct vg_shader *shader);
120 #endif