Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5564 serge 1
/*
2
 * Copyright © 2011 Intel Corporation
3
 *
4
 * Permission is hereby granted, free of charge, to any person obtaining a
5
 * copy of this software and associated documentation files (the "Software"),
6
 * to deal in the Software without restriction, including without limitation
7
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
 * and/or sell copies of the Software, and to permit persons to whom the
9
 * Software is furnished to do so, subject to the following conditions:
10
 *
11
 * The above copyright notice and this permission notice (including the next
12
 * paragraph) shall be included in all copies or substantial portions of the
13
 * Software.
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
 * DEALINGS IN THE SOFTWARE.
22
 */
23
 
24
/* This file declares stripped-down versions of functions that
25
 * normally exist outside of the glsl folder, so that they can be used
26
 * when running the GLSL compiler standalone (for unit testing or
27
 * compiling builtins).
28
 */
29
 
30
#include "standalone_scaffolding.h"
31
 
32
#include 
33
#include 
34
#include 
35
#include "util/ralloc.h"
36
 
37
void
38
_mesa_warning(struct gl_context *ctx, const char *fmt, ...)
39
{
40
    va_list vargs;
41
    (void) ctx;
42
 
43
    va_start(vargs, fmt);
44
 
45
    /* This output is not thread-safe, but that's good enough for the
46
     * standalone compiler.
47
     */
48
    fprintf(stderr, "Mesa warning: ");
49
    vfprintf(stderr, fmt, vargs);
50
    fprintf(stderr, "\n");
51
 
52
    va_end(vargs);
53
}
54
 
55
void
56
_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
57
                       struct gl_shader *sh)
58
{
59
   (void) ctx;
60
   *ptr = sh;
61
}
62
 
63
void
64
_mesa_shader_debug(struct gl_context *, GLenum, GLuint *id,
65
                   const char *, int)
66
{
67
}
68
 
69
struct gl_shader *
70
_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
71
{
72
   struct gl_shader *shader;
73
 
74
   (void) ctx;
75
 
76
   assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER);
77
   shader = rzalloc(NULL, struct gl_shader);
78
   if (shader) {
79
      shader->Type = type;
80
      shader->Stage = _mesa_shader_enum_to_shader_stage(type);
81
      shader->Name = name;
82
      shader->RefCount = 1;
83
   }
84
   return shader;
85
}
86
 
87
void
88
_mesa_clear_shader_program_data(struct gl_shader_program *shProg)
89
{
90
   unsigned i;
91
 
92
   shProg->NumUserUniformStorage = 0;
93
   shProg->UniformStorage = NULL;
94
   shProg->NumUniformRemapTable = 0;
95
   shProg->UniformRemapTable = NULL;
96
   shProg->UniformHash = NULL;
97
 
98
   ralloc_free(shProg->InfoLog);
99
   shProg->InfoLog = ralloc_strdup(shProg, "");
100
 
101
   ralloc_free(shProg->UniformBlocks);
102
   shProg->UniformBlocks = NULL;
103
   shProg->NumUniformBlocks = 0;
104
   for (i = 0; i < MESA_SHADER_STAGES; i++) {
105
      ralloc_free(shProg->UniformBlockStageIndex[i]);
106
      shProg->UniformBlockStageIndex[i] = NULL;
107
   }
108
 
109
   ralloc_free(shProg->AtomicBuffers);
110
   shProg->AtomicBuffers = NULL;
111
   shProg->NumAtomicBuffers = 0;
112
}
113
 
114
void initialize_context_to_defaults(struct gl_context *ctx, gl_api api)
115
{
116
   memset(ctx, 0, sizeof(*ctx));
117
 
118
   ctx->API = api;
119
 
120
   ctx->Extensions.dummy_false = false;
121
   ctx->Extensions.dummy_true = true;
122
   ctx->Extensions.ARB_compute_shader = true;
123
   ctx->Extensions.ARB_conservative_depth = true;
124
   ctx->Extensions.ARB_draw_instanced = true;
125
   ctx->Extensions.ARB_ES2_compatibility = true;
126
   ctx->Extensions.ARB_ES3_compatibility = true;
127
   ctx->Extensions.ARB_explicit_attrib_location = true;
128
   ctx->Extensions.ARB_fragment_coord_conventions = true;
129
   ctx->Extensions.ARB_fragment_layer_viewport = true;
130
   ctx->Extensions.ARB_gpu_shader5 = true;
131
   ctx->Extensions.ARB_gpu_shader_fp64 = true;
132
   ctx->Extensions.ARB_sample_shading = true;
133
   ctx->Extensions.ARB_shader_bit_encoding = true;
134
   ctx->Extensions.ARB_shader_stencil_export = true;
135
   ctx->Extensions.ARB_shader_texture_lod = true;
136
   ctx->Extensions.ARB_shading_language_420pack = true;
137
   ctx->Extensions.ARB_shading_language_packing = true;
138
   ctx->Extensions.ARB_texture_cube_map_array = true;
139
   ctx->Extensions.ARB_texture_gather = true;
140
   ctx->Extensions.ARB_texture_multisample = true;
141
   ctx->Extensions.ARB_texture_query_levels = true;
142
   ctx->Extensions.ARB_texture_query_lod = true;
143
   ctx->Extensions.ARB_uniform_buffer_object = true;
144
   ctx->Extensions.ARB_viewport_array = true;
145
 
146
   ctx->Extensions.OES_EGL_image_external = true;
147
   ctx->Extensions.OES_standard_derivatives = true;
148
 
149
   ctx->Extensions.EXT_shader_integer_mix = true;
150
   ctx->Extensions.EXT_texture3D = true;
151
   ctx->Extensions.EXT_texture_array = true;
152
 
153
   ctx->Extensions.NV_texture_rectangle = true;
154
 
155
   ctx->Const.GLSLVersion = 120;
156
 
157
   /* 1.20 minimums. */
158
   ctx->Const.MaxLights = 8;
159
   ctx->Const.MaxClipPlanes = 6;
160
   ctx->Const.MaxTextureUnits = 2;
161
   ctx->Const.MaxTextureCoordUnits = 2;
162
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs = 16;
163
 
164
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents = 512;
165
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxOutputComponents = 32;
166
   ctx->Const.MaxVarying = 8; /* == gl_MaxVaryingFloats / 4 */
167
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits = 0;
168
   ctx->Const.MaxCombinedTextureImageUnits = 2;
169
   ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits = 2;
170
   ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents = 64;
171
   ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents = 32;
172
 
173
   ctx->Const.MaxDrawBuffers = 1;
174
   ctx->Const.MaxComputeWorkGroupCount[0] = 65535;
175
   ctx->Const.MaxComputeWorkGroupCount[1] = 65535;
176
   ctx->Const.MaxComputeWorkGroupCount[2] = 65535;
177
   ctx->Const.MaxComputeWorkGroupSize[0] = 1024;
178
   ctx->Const.MaxComputeWorkGroupSize[1] = 1024;
179
   ctx->Const.MaxComputeWorkGroupSize[2] = 64;
180
   ctx->Const.MaxComputeWorkGroupInvocations = 1024;
181
   ctx->Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits = 16;
182
   ctx->Const.Program[MESA_SHADER_COMPUTE].MaxUniformComponents = 1024;
183
   ctx->Const.Program[MESA_SHADER_COMPUTE].MaxInputComponents = 0; /* not used */
184
   ctx->Const.Program[MESA_SHADER_COMPUTE].MaxOutputComponents = 0; /* not used */
185
 
186
   /* Set up default shader compiler options. */
187
   struct gl_shader_compiler_options options;
188
   memset(&options, 0, sizeof(options));
189
   options.MaxUnrollIterations = 32;
190
   options.MaxIfDepth = UINT_MAX;
191
 
192
   for (int sh = 0; sh < MESA_SHADER_STAGES; ++sh)
193
      memcpy(&ctx->Const.ShaderCompilerOptions[sh], &options, sizeof(options));
194
}