Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5564 serge 1
/**************************************************************************
2
 *
3
 * Copyright 2007 VMware, Inc.
4
 * All Rights Reserved.
5
 * Copyright 2010 VMware, Inc.  All rights reserved.
6
 *
7
 * Permission is hereby granted, free of charge, to any person obtaining a
8
 * copy of this software and associated documentation files (the
9
 * "Software"), to deal in the Software without restriction, including
10
 * without limitation the rights to use, copy, modify, merge, publish,
11
 * distribute, sub license, and/or sell copies of the Software, and to
12
 * permit persons to whom the Software is furnished to do so, subject to
13
 * the following conditions:
14
 *
15
 * The above copyright notice and this permission notice (including the
16
 * next paragraph) shall be included in all copies or substantial portions
17
 * of the Software.
18
 *
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22
 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
23
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
 *
27
 **************************************************************************/
28
 
29
#ifndef SP_TEX_SAMPLE_H
30
#define SP_TEX_SAMPLE_H
31
 
32
 
33
#include "tgsi/tgsi_exec.h"
34
 
35
 
36
struct sp_sampler_view;
37
struct sp_sampler;
38
 
39
typedef void (*wrap_nearest_func)(float s,
40
                                  unsigned size,
41
                                  int *icoord);
42
 
43
typedef void (*wrap_linear_func)(float s,
44
                                 unsigned size,
45
                                 int *icoord0,
46
                                 int *icoord1,
47
                                 float *w);
48
 
49
typedef float (*compute_lambda_func)(const struct sp_sampler_view *sp_sview,
50
                                     const float s[TGSI_QUAD_SIZE],
51
                                     const float t[TGSI_QUAD_SIZE],
52
                                     const float p[TGSI_QUAD_SIZE]);
53
 
54
typedef void (*img_filter_func)(struct sp_sampler_view *sp_sview,
55
                                struct sp_sampler *sp_samp,
56
                                float s,
57
                                float t,
58
                                float p,
59
                                unsigned level,
60
                                unsigned face_id,
61
                                float *rgba);
62
 
63
typedef void (*mip_filter_func)(struct sp_sampler_view *sp_sview,
64
                                struct sp_sampler *sp_samp,
65
                                img_filter_func min_filter,
66
                                img_filter_func mag_filter,
67
                                const float s[TGSI_QUAD_SIZE],
68
                                const float t[TGSI_QUAD_SIZE],
69
                                const float p[TGSI_QUAD_SIZE],
70
                                const float c0[TGSI_QUAD_SIZE],
71
                                const float lod[TGSI_QUAD_SIZE],
72
                                enum tgsi_sampler_control control,
73
                                float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]);
74
 
75
 
76
typedef void (*filter_func)(struct sp_sampler_view *sp_sview,
77
                            struct sp_sampler *sp_samp,
78
                            const float s[TGSI_QUAD_SIZE],
79
                            const float t[TGSI_QUAD_SIZE],
80
                            const float p[TGSI_QUAD_SIZE],
81
                            const float c0[TGSI_QUAD_SIZE],
82
                            const float lod[TGSI_QUAD_SIZE],
83
                            enum tgsi_sampler_control control,
84
                            float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]);
85
 
86
 
87
typedef void (*fetch_func)(struct sp_sampler_view *sp_sview,
88
                           const int i[TGSI_QUAD_SIZE],
89
                           const int j[TGSI_QUAD_SIZE], const int k[TGSI_QUAD_SIZE],
90
                           const int lod[TGSI_QUAD_SIZE], const int8_t offset[3],
91
                           float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]);
92
 
93
 
94
struct sp_sampler_view
95
{
96
   struct pipe_sampler_view base;
97
 
98
   /* For sp_get_samples_2d_linear_POT:
99
    */
100
   unsigned xpot;
101
   unsigned ypot;
102
 
103
   boolean need_swizzle;
104
   boolean pot2d;
105
 
106
   filter_func get_samples;
107
 
108
   /* this is just abusing the sampler_view object as local storage */
109
   unsigned faces[TGSI_QUAD_SIZE];
110
 
111
   /* these are different per shader type */
112
   struct softpipe_tex_tile_cache *cache;
113
   compute_lambda_func compute_lambda;
114
 
115
};
116
 
117
 
118
struct sp_sampler {
119
   struct pipe_sampler_state base;
120
 
121
   boolean min_mag_equal_repeat_linear;
122
   boolean min_mag_equal;
123
   unsigned min_img_filter;
124
 
125
   wrap_nearest_func nearest_texcoord_s;
126
   wrap_nearest_func nearest_texcoord_t;
127
   wrap_nearest_func nearest_texcoord_p;
128
 
129
   wrap_linear_func linear_texcoord_s;
130
   wrap_linear_func linear_texcoord_t;
131
   wrap_linear_func linear_texcoord_p;
132
 
133
   mip_filter_func mip_filter;
134
};
135
 
136
 
137
/**
138
 * Subclass of tgsi_sampler
139
 */
140
struct sp_tgsi_sampler
141
{
142
   struct tgsi_sampler base;  /**< base class */
143
   struct sp_sampler *sp_sampler[PIPE_MAX_SAMPLERS];
144
   struct sp_sampler_view sp_sview[PIPE_MAX_SHADER_SAMPLER_VIEWS];
145
 
146
};
147
 
148
compute_lambda_func
149
softpipe_get_lambda_func(const struct pipe_sampler_view *view, unsigned shader);
150
 
151
 
152
void *
153
softpipe_create_sampler_state(struct pipe_context *pipe,
154
                              const struct pipe_sampler_state *sampler);
155
 
156
 
157
struct pipe_sampler_view *
158
softpipe_create_sampler_view(struct pipe_context *pipe,
159
                             struct pipe_resource *resource,
160
                             const struct pipe_sampler_view *templ);
161
 
162
 
163
struct sp_tgsi_sampler *
164
sp_create_tgsi_sampler(void);
165
 
166
 
167
#endif /* SP_TEX_SAMPLE_H */