compiler: Turn on enough to invoke front end during XGL execution
Remove glassy compile checks, fix more things to run glsl
Consume glsl in the stack, store resulting IR
Fix up things enough to invoke our shader compiler with glsl, via
the real XGL calls. Store the result as a gl_shader_program which
contains the IR.
The test still consumes the ISA generated by hand, but it will
print out the IR generated by xglCreateShader. It will continue
to use hand ISA until we implement xglCreateGraphicsPipeline, which
will lower the IR to ISA using NOS.
diff --git a/icd/intel/compiler/mesa-utils/src/mesa/main/compiler.h b/icd/intel/compiler/mesa-utils/src/mesa/main/compiler.h
index 97075f5..f91bb08 100644
--- a/icd/intel/compiler/mesa-utils/src/mesa/main/compiler.h
+++ b/icd/intel/compiler/mesa-utils/src/mesa/main/compiler.h
@@ -243,10 +243,6 @@
* Basically, use COND to dimension an array. If COND is false/zero the
* array size will be -1 and we'll get a compilation error.
*/
-#define STATIC_ASSERT(COND) \
- do { \
- (void) sizeof(char [1 - 2*!(COND)]); \
- } while (0)
/**
* Unreachable macro. Useful for suppressing "control reaches end of non-void
diff --git a/icd/intel/compiler/mesa-utils/src/mesa/main/enums.c b/icd/intel/compiler/mesa-utils/src/mesa/main/enums.c
index 51651ac..50e4409 100644
--- a/icd/intel/compiler/mesa-utils/src/mesa/main/enums.c
+++ b/icd/intel/compiler/mesa-utils/src/mesa/main/enums.c
@@ -25,6 +25,7 @@
* SOFTWARE.
*/
+#include "icd-utils.h" // LunarG: ADD
#include "main/glheader.h"
#include "main/enums.h"
#include "main/imports.h"
diff --git a/icd/intel/compiler/mesa-utils/src/mesa/main/hash_table.c b/icd/intel/compiler/mesa-utils/src/mesa/main/hash_table.c
index ad8f898..d6c5851 100644
--- a/icd/intel/compiler/mesa-utils/src/mesa/main/hash_table.c
+++ b/icd/intel/compiler/mesa-utils/src/mesa/main/hash_table.c
@@ -43,6 +43,7 @@
#include <stdlib.h>
#include <string.h>
+#include "icd-utils.h" // LunarG: ADD
#include "main/hash_table.h"
#include "main/macros.h"
#include "ralloc.h"
diff --git a/icd/intel/compiler/mesa-utils/src/mesa/main/macros.h b/icd/intel/compiler/mesa-utils/src/mesa/main/macros.h
index 5228c3a..abb5ef8 100644
--- a/icd/intel/compiler/mesa-utils/src/mesa/main/macros.h
+++ b/icd/intel/compiler/mesa-utils/src/mesa/main/macros.h
@@ -818,7 +818,7 @@
#define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE)
/* Compute the size of an array */
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+//#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
/* Stringify */
#define STRINGIFY(x) #x
diff --git a/icd/intel/compiler/mesa-utils/src/mesa/program/prog_diskcache.c b/icd/intel/compiler/mesa-utils/src/mesa/program/prog_diskcache.c
index d8873c0..f9b52e6 100644
--- a/icd/intel/compiler/mesa-utils/src/mesa/program/prog_diskcache.c
+++ b/icd/intel/compiler/mesa-utils/src/mesa/program/prog_diskcache.c
@@ -25,10 +25,7 @@
#include <sys/stat.h>
#include "shader_cache.h"
#include "prog_diskcache.h"
-
-#ifdef USE_LUNARGLASS
#include "glsl_parser_extras.h"
-#endif
#ifndef _WIN32
#include <dirent.h>
@@ -265,11 +262,9 @@
if (!key)
return -1;
-#ifdef USE_LUNARGLASS
/* Glassy vs. Opaque compiled shaders */
if (_mesa_use_glass(ctx))
ralloc_strcat(&key, ".g");
-#endif
char *shader_path =
ralloc_asprintf(NULL, "%s/%s.bin", ctx->BinaryProgramCachePath, key);
@@ -377,11 +372,9 @@
if (!key)
return -1;
-#ifdef USE_LUNARGLASS
/* Glassy vs. Opaque compiled shaders */
if (_mesa_use_glass(ctx))
ralloc_strcat(&key, ".g");
-#endif
char *shader_path =
@@ -587,11 +580,9 @@
if (!key)
return -1;
-#ifdef USE_LUNARGLASS
/* Glassy vs. Opaque compiled shaders */
if (_mesa_use_glass(ctx))
ralloc_strcat(&key, ".g");
-#endif
char *shader_path =
ralloc_asprintf(NULL, "%s/%s.bin", ctx->BinaryShaderCachePath, key);
@@ -650,12 +641,9 @@
if (!key)
return -1;
-#ifdef USE_LUNARGLASS
/* Glassy vs. Opaque compiled shaders */
if (_mesa_use_glass(ctx))
ralloc_strcat(&key, ".g");
-#endif
-
char *shader_path =
ralloc_asprintf(NULL, "%s/%s.bin", ctx->BinaryShaderCachePath, key);
diff --git a/icd/intel/compiler/mesa-utils/src/mesa/program/program.c b/icd/intel/compiler/mesa-utils/src/mesa/program/program.c
index 6d8b8f3..82d5af8 100644
--- a/icd/intel/compiler/mesa-utils/src/mesa/program/program.c
+++ b/icd/intel/compiler/mesa-utils/src/mesa/program/program.c
@@ -29,6 +29,7 @@
*/
+#include "icd-utils.h" // LunarG: ADD
#include "main/glheader.h"
#include "main/context.h"
#include "main/hash.h"
diff --git a/icd/intel/compiler/shader/ast_to_hir.cpp b/icd/intel/compiler/shader/ast_to_hir.cpp
index 009c823..b429b0f 100644
--- a/icd/intel/compiler/shader/ast_to_hir.cpp
+++ b/icd/intel/compiler/shader/ast_to_hir.cpp
@@ -50,6 +50,7 @@
*/
#include "libfns.h" // LunarG ADD:
+#include "icd-utils.h" // LunarG ADD:
#include "glsl_symbol_table.h"
#include "glsl_parser_extras.h"
#include "ast.h"
diff --git a/icd/intel/compiler/shader/compiler_interface.cpp b/icd/intel/compiler/shader/compiler_interface.cpp
new file mode 100644
index 0000000..0072d07
--- /dev/null
+++ b/icd/intel/compiler/shader/compiler_interface.cpp
@@ -0,0 +1,258 @@
+/*
+ * XGL
+ *
+ * Copyright (C) 2014 LunarG, Inc.
+ *
+ * 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 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.
+ *
+ * Authors:
+ * LunarG
+ */
+
+#include "icd-bil.h"
+#include "shader.h"
+#include "compiler_interface.h"
+#include "compiler/mesa-utils/src/glsl/ralloc.h"
+#include "compiler/shader/glsl_parser_extras.h"
+#include "compiler/shader/program.h"
+#include "compiler/mesa-utils/src/mesa/main/context.h"
+#include "compiler/shader/standalone_scaffolding.h"
+
+namespace {
+
+void initialize_mesa_context_to_defaults(struct gl_context *ctx)
+{
+ memset(ctx, 0, sizeof(*ctx));
+
+ ctx->API = API_OPENGL_CORE;
+
+ ctx->Extensions.dummy_false = false;
+ ctx->Extensions.dummy_true = true;
+ ctx->Extensions.ARB_compute_shader = true;
+ ctx->Extensions.ARB_conservative_depth = true;
+ ctx->Extensions.ARB_draw_instanced = true;
+ ctx->Extensions.ARB_ES2_compatibility = true;
+ ctx->Extensions.ARB_ES3_compatibility = true;
+ ctx->Extensions.ARB_explicit_attrib_location = true;
+ ctx->Extensions.ARB_fragment_coord_conventions = true;
+ ctx->Extensions.ARB_gpu_shader5 = true;
+ ctx->Extensions.ARB_sample_shading = true;
+ ctx->Extensions.ARB_shader_bit_encoding = true;
+ ctx->Extensions.ARB_shader_stencil_export = true;
+ ctx->Extensions.ARB_shader_texture_lod = true;
+ ctx->Extensions.ARB_shading_language_420pack = true;
+ ctx->Extensions.ARB_shading_language_packing = true;
+ ctx->Extensions.ARB_texture_cube_map_array = true;
+ ctx->Extensions.ARB_texture_gather = true;
+ ctx->Extensions.ARB_texture_multisample = true;
+ ctx->Extensions.ARB_texture_query_levels = true;
+ ctx->Extensions.ARB_texture_query_lod = true;
+ ctx->Extensions.ARB_uniform_buffer_object = true;
+ ctx->Extensions.ARB_viewport_array = true;
+ ctx->Extensions.OES_EGL_image_external = true;
+ ctx->Extensions.OES_standard_derivatives = true;
+ ctx->Extensions.EXT_shader_integer_mix = true;
+ ctx->Extensions.EXT_texture3D = true;
+ ctx->Extensions.EXT_texture_array = true;
+ ctx->Extensions.NV_texture_rectangle = true;
+ ctx->Const.GLSLVersion = 330;
+
+ ctx->Const.MaxComputeWorkGroupCount[0] = 65535;
+ ctx->Const.MaxComputeWorkGroupCount[1] = 65535;
+ ctx->Const.MaxComputeWorkGroupCount[2] = 65535;
+ ctx->Const.MaxComputeWorkGroupSize[0] = 1024;
+ ctx->Const.MaxComputeWorkGroupSize[1] = 1024;
+ ctx->Const.MaxComputeWorkGroupSize[2] = 64;
+ ctx->Const.MaxComputeWorkGroupInvocations = 1024;
+ ctx->Const.Program[MESA_SHADER_COMPUTE].MaxTextureImageUnits = 16;
+ ctx->Const.Program[MESA_SHADER_COMPUTE].MaxUniformComponents = 1024;
+ ctx->Const.Program[MESA_SHADER_COMPUTE].MaxInputComponents = 0; /* not used */
+ ctx->Const.Program[MESA_SHADER_COMPUTE].MaxOutputComponents = 0; /* not used */
+
+
+ /* 3.30 minimums. */
+ ctx->Const.MaxLights = 8;
+ ctx->Const.MaxClipPlanes = 8;
+ ctx->Const.MaxTextureUnits = 2;
+ ctx->Const.MaxTextureCoordUnits = 8;
+ ctx->Const.MaxVarying = 60 / 4;
+ ctx->Const.MaxDrawBuffers = 1;
+
+ ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs = 16;
+ ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits = 16;
+ ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents = 1024;
+ ctx->Const.Program[MESA_SHADER_VERTEX].MaxInputComponents = 0; /* not used */
+ ctx->Const.Program[MESA_SHADER_VERTEX].MaxOutputComponents = 64;
+
+ ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits = 16;
+ ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxUniformComponents = 1024;
+ ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxInputComponents =
+ ctx->Const.Program[MESA_SHADER_VERTEX].MaxOutputComponents;
+ ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxOutputComponents = 128;
+
+ ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits = 16;
+ ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents = 1024;
+ ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents =
+ ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxOutputComponents;
+ ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxOutputComponents = 0; /* not used */
+
+ ctx->Const.MaxCombinedTextureImageUnits =
+ ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits
+ + ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits
+ + ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits;
+
+ ctx->Const.MaxGeometryOutputVertices = 256;
+ ctx->Const.MaxGeometryTotalOutputComponents = 1024;
+
+
+ /* Set up default shader compiler options. */
+ struct gl_shader_compiler_options options;
+ memset(&options, 0, sizeof(options));
+ options.MaxUnrollIterations = 32;
+ options.MaxIfDepth = UINT_MAX;
+
+ /* Default pragma settings */
+ options.DefaultPragmas.Optimize = true;
+
+ for (int sh = 0; sh < MESA_SHADER_STAGES; ++sh)
+ memcpy(&ctx->ShaderCompilerOptions[sh], &options, sizeof(options));
+
+
+ ctx->Driver.NewShader = _mesa_new_shader;
+ ctx->Driver.DeleteShader = _mesa_delete_shader;
+}
+
+} // namespace
+
+
+extern "C" {
+
+// invoke front end compiler to generate an independently linked
+// program object that contains Mesa HIR
+struct gl_shader_program *shader_create_program(struct intel_shader *sh,
+ const struct icd_bil_header *bil)
+{
+ struct gl_context local_ctx;
+ struct gl_context *ctx = &local_ctx;
+
+ _mesa_create_shader_compiler();
+ initialize_mesa_context_to_defaults(ctx);
+
+ struct gl_shader_program *shader_program;
+
+ shader_program = rzalloc (NULL, struct gl_shader_program);
+ assert(shader_program != NULL);
+ shader_program->InfoLog = ralloc_strdup(shader_program, "");
+
+ shader_program->Shaders =
+ reralloc(shader_program, shader_program->Shaders,
+ struct gl_shader *, shader_program->NumShaders + 1);
+ assert(shader_program->Shaders != NULL);
+
+ struct gl_shader *shader = rzalloc(shader_program, struct gl_shader);
+
+ shader_program->Shaders[shader_program->NumShaders] = shader;
+ shader_program->NumShaders++;
+
+
+ // We should parse the glsl text out of bil right now, but
+ // instead we are just plopping down our glsl
+ switch(bil->gen_magic) {
+ case 'v':
+ shader_program->Shaders[0]->Source =
+ "#version 130\n"
+ "void main() {\n"
+ " vec2 vertices[3];"
+ " vertices[0] = vec2(-1.0, -1.0);\n"
+ " vertices[1] = vec2( 1.0, -1.0);\n"
+ " vertices[2] = vec2( 0.0, 1.0);\n"
+ " gl_Position = vec4(vertices[gl_VertexID % 3], 0.0, 1.0);\n"
+ "}\n";
+ break;
+ case 'w':
+ shader_program->Shaders[0]->Source =
+ "#version 130\n"
+ "void main() {\n"
+ " gl_FragColor = vec4(1.0,0.0,0.0,1.0);\n"
+ "}\n";
+ break;
+ default:
+ assert(0);
+ break;
+ }
+
+ switch(bil->gen_magic) {
+ case 'v':
+ shader->Type = GL_VERTEX_SHADER;
+ break;
+ case 'w':
+ shader->Type = GL_FRAGMENT_SHADER;
+ break;
+ default:
+ //shader->Type = GL_GEOMETRY_SHADER;
+ //shader->Type = GL_COMPUTE_SHADER;
+ assert(0);
+ break;
+ }
+
+ struct _mesa_glsl_parse_state *state =
+ new(shader) _mesa_glsl_parse_state(ctx, shader->Stage, shader);
+
+ shader->Stage = _mesa_shader_enum_to_shader_stage(shader->Type);
+
+ bool dump_ast = false;
+ bool dump_hir = true;
+ bool do_link = true;
+
+ _mesa_glsl_compile_shader(ctx, shader, dump_ast, dump_hir);
+
+ if (strlen(shader->InfoLog) > 0)
+ printf("Info log:\n%s\n", shader->InfoLog);
+
+ if (!shader->CompileStatus)
+ return NULL;
+
+ assert(shader_program->NumShaders == 1);
+
+ // for XGL, we are independently compiling and linking individual
+ // shaders, which matches this frontend's concept of SSO
+ shader_program->SeparateShader = true;
+
+ link_shaders(ctx, shader_program);
+ if (!shader_program->LinkStatus)
+ return NULL;
+
+ if (strlen(shader_program->InfoLog) > 0)
+ printf("Info log for linking:\n%s\n", shader_program->InfoLog);
+
+ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++)
+ ralloc_free(shader_program->_LinkedShaders[i]);
+
+ _mesa_destroy_shader_compiler();
+
+ return shader_program;
+}
+
+
+void shader_destroy_program(struct gl_shader_program *shader_program)
+{
+ ralloc_free(shader_program);
+}
+
+} // extern "C"
diff --git a/icd/intel/compiler/shader/compiler_interface.h b/icd/intel/compiler/shader/compiler_interface.h
new file mode 100644
index 0000000..c381c51
--- /dev/null
+++ b/icd/intel/compiler/shader/compiler_interface.h
@@ -0,0 +1,48 @@
+/*
+ * XGL
+ *
+ * Copyright (C) 2014 LunarG, Inc.
+ *
+ * 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 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.
+ *
+ * Authors:
+ * LunarG
+ */
+
+#ifndef COMPILER_INTERFACE_H
+#define COMPILER_INTERFACE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+struct intel_shader;
+struct icd_bil_header;
+
+struct gl_shader_program *shader_create_program(struct intel_shader *sh,
+ const struct icd_bil_header *bil);
+
+void shader_destroy_program(struct gl_shader_program *shader_program);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif /* COMPILER_INTERFACE_H */
diff --git a/icd/intel/compiler/shader/glsl_glass_backend.cpp b/icd/intel/compiler/shader/glsl_glass_backend.cpp
index 3b98634..53a14b0 100644
--- a/icd/intel/compiler/shader/glsl_glass_backend.cpp
+++ b/icd/intel/compiler/shader/glsl_glass_backend.cpp
@@ -40,8 +40,6 @@
//
//===----------------------------------------------------------------------===//
-#ifdef USE_LUNARGLASS
-
#include "glsl_glass_backend.h"
namespace gla {
@@ -60,6 +58,3 @@
}
} // namespace gla
-
-#endif // USE_LUNARGLASS
-
diff --git a/icd/intel/compiler/shader/glsl_glass_backend.h b/icd/intel/compiler/shader/glsl_glass_backend.h
index c74d537..6feb58a 100644
--- a/icd/intel/compiler/shader/glsl_glass_backend.h
+++ b/icd/intel/compiler/shader/glsl_glass_backend.h
@@ -40,8 +40,6 @@
//
//===----------------------------------------------------------------------===//
-#ifdef USE_LUNARGLASS
-
#include "Core/Backend.h"
#include "glslang/Public/ShaderLang.h"
@@ -145,5 +143,3 @@
void ReleaseMesaGlassBackEnd(BackEnd*);
} // namespace gla
-
-# endif // USE_LUNARGLASS
diff --git a/icd/intel/compiler/shader/glsl_glass_backend_translator.cpp b/icd/intel/compiler/shader/glsl_glass_backend_translator.cpp
index 7ac72cb..f1f1145 100644
--- a/icd/intel/compiler/shader/glsl_glass_backend_translator.cpp
+++ b/icd/intel/compiler/shader/glsl_glass_backend_translator.cpp
@@ -40,8 +40,6 @@
//
//===----------------------------------------------------------------------===//
-#ifdef USE_LUNARGLASS
-
// LunarGLASS includes
#include "Core/Revision.h"
#include "Core/Exceptions.h"
@@ -3685,5 +3683,3 @@
}
} // namespace gla
-
-#endif // USE_LUNARGLASS
diff --git a/icd/intel/compiler/shader/glsl_glass_backend_translator.h b/icd/intel/compiler/shader/glsl_glass_backend_translator.h
index 57d7613..b41f414 100644
--- a/icd/intel/compiler/shader/glsl_glass_backend_translator.h
+++ b/icd/intel/compiler/shader/glsl_glass_backend_translator.h
@@ -40,9 +40,6 @@
//
//===----------------------------------------------------------------------===//
-
-#ifdef USE_LUNARGLASS
-
#include "Core/PrivateManager.h"
#include "Core/Backend.h"
#include "list.h"
@@ -427,5 +424,3 @@
gl_context* ctx;
}; // class MesaGlassTranslator
} // namespace gla
-
-#endif // USE_LUNARGLASS
diff --git a/icd/intel/compiler/shader/glsl_glass_manager.cpp b/icd/intel/compiler/shader/glsl_glass_manager.cpp
index 2a74c05..83507b2 100644
--- a/icd/intel/compiler/shader/glsl_glass_manager.cpp
+++ b/icd/intel/compiler/shader/glsl_glass_manager.cpp
@@ -40,8 +40,6 @@
//
//===----------------------------------------------------------------------===//
-#ifdef USE_LUNARGLASS
-
#include "glsl_glass_manager.h"
#include "glsl_glass_backend.h"
#include "glsl_glass_backend_translator.h"
@@ -99,5 +97,3 @@
// get them from our factory, which only makes MesaGlassTranslators.
return static_cast<gla::MesaGlassTranslator*>(backEndTranslator);
}
-
-#endif // USE_LUNARGLASS
diff --git a/icd/intel/compiler/shader/glsl_glass_manager.h b/icd/intel/compiler/shader/glsl_glass_manager.h
index f9ca621..c658608 100644
--- a/icd/intel/compiler/shader/glsl_glass_manager.h
+++ b/icd/intel/compiler/shader/glsl_glass_manager.h
@@ -40,8 +40,6 @@
//
//===----------------------------------------------------------------------===//
-#ifdef USE_LUNARGLASS
-
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch"
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
@@ -70,5 +68,3 @@
Manager* getManager(const EShLanguage);
} // namespace gla
-
-#endif // USE_LUNARGLASS
diff --git a/icd/intel/compiler/shader/glsl_parser_extras.cpp b/icd/intel/compiler/shader/glsl_parser_extras.cpp
index f57f51a..064d9b7 100644
--- a/icd/intel/compiler/shader/glsl_parser_extras.cpp
+++ b/icd/intel/compiler/shader/glsl_parser_extras.cpp
@@ -25,17 +25,16 @@
#include <string.h>
#include <assert.h>
-#ifdef USE_LUNARGLASS
// These #includes MUST be provided before glext.h, which pollutes the global namespace.
#include "glslang/Include/ShHandle.h"
#include "glslang/Public/ShaderLang.h"
#include "Frontends/glslang/GlslangToTop.h"
#include "glsl_glass_manager.h"
#include "glsl_glass_backend_translator.h"
-#endif // USE_LUNARGLASS
extern "C" {
#include "libfns.h" // LunarG ADD:
+#include "icd-utils.h" // LunarG ADD:
#include "main/context.h"
#include "main/shaderobj.h"
#include "program/prog_diskcache.h"
@@ -1473,8 +1472,6 @@
extern "C" {
-#ifdef USE_LUNARGLASS
-
void _mesa_glslang_generate_resources(struct gl_context *ctx,
TBuiltInResource& resources)
{
@@ -1733,25 +1730,11 @@
delete manager;
}
-#endif // USE_LUNARGLASS
-
void
_mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
bool dump_ast, bool dump_hir)
{
-#ifdef USE_LUNARGLASS
- // Temporary shader source blacklist, until a source of falling back into SIMD8 can be fixed.
- const bool blacklist =
- (strstr(shader->Source, "963210701942") != 0) ||
- (strstr(shader->Source, "GL_ARB_texture_multisample") != 0);
-
- if (!blacklist && _mesa_use_glass(ctx)) {
- _mesa_glsl_compile_shader_glass(ctx, shader, dump_ast, dump_hir);
- } else {
-#endif // USE_LUNARGLASS
-#ifdef USE_LUNARGLASS
- }
-#endif // USE_LUNARGLASS
+ _mesa_glsl_compile_shader_glass(ctx, shader, dump_ast, dump_hir);
}
} /* extern "C" */
@@ -1843,12 +1826,15 @@
void
_mesa_create_shader_compiler(void)
{
-#ifdef USE_LUNARGLASS
+ static bool initialized;
+
// Initialize glslang and LunarGlass
- glslang::InitializeProcess();
- gla::Manager::startMultithreaded();
- gla::MesaGlassTranslator::initSamplerTypes();
-#endif // USE_LUNARGLASS
+ if (!initialized) {
+ glslang::InitializeProcess();
+ gla::Manager::startMultithreaded();
+ gla::MesaGlassTranslator::initSamplerTypes();
+ initialized = true;
+ }
}
/**
diff --git a/icd/intel/compiler/shader/ir_print_visitor.cpp b/icd/intel/compiler/shader/ir_print_visitor.cpp
index 6f370b9..89288db 100644
--- a/icd/intel/compiler/shader/ir_print_visitor.cpp
+++ b/icd/intel/compiler/shader/ir_print_visitor.cpp
@@ -21,6 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include "icd-utils.h" // LunarG: ADD
#include "ir_print_visitor.h"
#include "glsl_types.h"
#include "glsl_parser_extras.h"
diff --git a/icd/intel/compiler/shader/link_uniform_blocks.cpp b/icd/intel/compiler/shader/link_uniform_blocks.cpp
index 6430c34..9169f94 100644
--- a/icd/intel/compiler/shader/link_uniform_blocks.cpp
+++ b/icd/intel/compiler/shader/link_uniform_blocks.cpp
@@ -22,6 +22,7 @@
*/
#include "libfns.h" // LunarG ADD:
+#include "icd-utils.h" // LunarG ADD:
#include "ir.h"
#include "linker.h"
#include "ir_uniform.h"
diff --git a/icd/intel/compiler/shader/link_uniforms.cpp b/icd/intel/compiler/shader/link_uniforms.cpp
index 3d98f75..9371347 100644
--- a/icd/intel/compiler/shader/link_uniforms.cpp
+++ b/icd/intel/compiler/shader/link_uniforms.cpp
@@ -22,6 +22,7 @@
*/
#include "libfns.h" // LunarG ADD:
+#include "icd-utils.h" // LunarG: ADD
#include "ir.h"
#include "linker.h"
#include "ir_uniform.h"
diff --git a/icd/intel/compiler/shader/link_varyings.cpp b/icd/intel/compiler/shader/link_varyings.cpp
index ac38a2f..2543045 100644
--- a/icd/intel/compiler/shader/link_varyings.cpp
+++ b/icd/intel/compiler/shader/link_varyings.cpp
@@ -29,6 +29,7 @@
*/
+#include "icd-utils.h" // LunarG: ADD
#include "main/mtypes.h"
#include "glsl_symbol_table.h"
#include "glsl_parser_extras.h"
diff --git a/icd/intel/compiler/shader/linker.cpp b/icd/intel/compiler/shader/linker.cpp
index 6f3b876..a55c7c6 100644
--- a/icd/intel/compiler/shader/linker.cpp
+++ b/icd/intel/compiler/shader/linker.cpp
@@ -74,9 +74,9 @@
#include "link_varyings.h"
#include "ir_optimization.h"
#include "ir_rvalue_visitor.h"
+#include "standalone_scaffolding.h" // LunarG ADD:
extern "C" {
-#include "main/shaderobj.h"
#include "main/enums.h"
}
@@ -1255,8 +1255,8 @@
"layout qualifiers for gl_FragCoord\n");
}
- /* Update the linked shader state. Note that uses_gl_fragcoord should
- * accumulate the results. The other values should replace. If there
+ /* Update the linked shader state. Note that uses_gl_fragcoord should
+ * accumulate the results. The other values should replace. If there
* are multiple redeclarations, all the fields except uses_gl_fragcoord
* are already known to be the same.
*/
diff --git a/icd/intel/compiler/shader/opt_dead_builtin_varyings.cpp b/icd/intel/compiler/shader/opt_dead_builtin_varyings.cpp
index 7e29b9b..aacf0fa 100644
--- a/icd/intel/compiler/shader/opt_dead_builtin_varyings.cpp
+++ b/icd/intel/compiler/shader/opt_dead_builtin_varyings.cpp
@@ -47,6 +47,7 @@
*/
#include "libfns.h" // LunarG ADD:
+#include "icd-utils.h" // LunarG: ADD
#include "ir.h"
#include "ir_rvalue_visitor.h"
#include "ir_optimization.h"
diff --git a/icd/intel/compiler/shader/ossource.cpp b/icd/intel/compiler/shader/ossource.cpp
index 5ac738d..c04a3dd 100644
--- a/icd/intel/compiler/shader/ossource.cpp
+++ b/icd/intel/compiler/shader/ossource.cpp
@@ -36,8 +36,6 @@
// This file contains the Linux-specific functions
//
-#ifdef USE_LUNARGLASS
-
#include "glslang/OSDependent/Linux/osinclude.h"
#include "glsl_parser_extras.h"
@@ -176,5 +174,3 @@
}
} // end namespace glslang
-
-#endif
diff --git a/icd/intel/compiler/shader/standalone_scaffolding.cpp b/icd/intel/compiler/shader/standalone_scaffolding.cpp
index 7d34e90..64c8558 100644
--- a/icd/intel/compiler/shader/standalone_scaffolding.cpp
+++ b/icd/intel/compiler/shader/standalone_scaffolding.cpp
@@ -59,6 +59,14 @@
*ptr = sh;
}
+void
+_mesa_reference_program(struct gl_context *ctx, struct gl_program **ptr,
+ struct gl_program *prog)
+{
+ (void) ctx;
+ *ptr = prog;
+}
+
//void
//_mesa_shader_debug(struct gl_context *, GLenum, GLuint *id,
// const char *, int)
@@ -83,6 +91,15 @@
return shader;
}
+void _mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh)
+{
+ free((void *)sh->Source);
+ free(sh->Label);
+ _mesa_reference_program(ctx, &sh->Program, NULL);
+ ralloc_free(sh);
+}
+
+
void initialize_context_to_defaults(struct gl_context *ctx, gl_api api)
{
memset(ctx, 0, sizeof(*ctx));
diff --git a/icd/intel/compiler/shader/standalone_scaffolding.h b/icd/intel/compiler/shader/standalone_scaffolding.h
index df783af..ce5d4e3 100644
--- a/icd/intel/compiler/shader/standalone_scaffolding.h
+++ b/icd/intel/compiler/shader/standalone_scaffolding.h
@@ -41,9 +41,18 @@
_mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
struct gl_shader *sh);
+// LunarG ADD:
+extern "C" void
+_mesa_reference_program(struct gl_context *ctx, struct gl_program **ptr,
+ struct gl_program *prog);
+
extern "C" struct gl_shader *
_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type);
+// LunarG ADD:
+extern "C" void
+_mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh);
+
extern "C" void
_mesa_shader_debug(struct gl_context *ctx, GLenum type, GLuint *id,
const char *msg, int len);
diff --git a/icd/intel/compiler/shader/tests/general_ir_test.cpp b/icd/intel/compiler/shader/tests/general_ir_test.cpp
index 862fa19..7bff56b 100644
--- a/icd/intel/compiler/shader/tests/general_ir_test.cpp
+++ b/icd/intel/compiler/shader/tests/general_ir_test.cpp
@@ -20,6 +20,7 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
+#include "icd-utils.h" // LunarG ADD:
#include <gtest/gtest.h>
#include "main/compiler.h"
#include "main/mtypes.h"