blob: 429bbf2e4250e7bf1c476a18437fef82a4014773 [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
shannon.woods%transgaming.com@gtempaccount.com0bbed382013-04-13 03:38:07 +00002// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7//
alokp@chromium.org774d7062010-07-21 18:55:45 +00008// Implement the top-level of interface to the compiler,
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00009// as defined in ShaderLang.h
10//
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011
alokp@chromium.orgea0e1af2010-03-22 19:33:14 +000012#include "GLSLANG/ShaderLang.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000013
Jamie Madilld4a3a312014-06-25 16:04:56 -040014#include "compiler/translator/Compiler.h"
Geoff Lang17732822013-08-29 13:46:49 -040015#include "compiler/translator/InitializeDll.h"
Jamie Madill5508f392014-02-20 13:31:36 -050016#include "compiler/translator/length_limits.h"
Daniel Bratell73941de2015-02-25 14:34:49 +010017#ifdef ANGLE_ENABLE_HLSL
Geoff Lang17732822013-08-29 13:46:49 -040018#include "compiler/translator/TranslatorHLSL.h"
Daniel Bratell73941de2015-02-25 14:34:49 +010019#endif // ANGLE_ENABLE_HLSL
Geoff Lang17732822013-08-29 13:46:49 -040020#include "compiler/translator/VariablePacker.h"
Jamie Madilla718c1e2014-07-02 15:31:22 -040021#include "angle_gl.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000022
Jamie Madille294bb82014-07-17 14:16:26 -040023namespace
24{
25
Jamie Madille294bb82014-07-17 14:16:26 -040026bool isInitialized = false;
Jamie Madillb4d192c2014-02-26 09:54:10 -050027
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000028//
29// This is the platform independent interface between an OGL driver
alokp@chromium.org774d7062010-07-21 18:55:45 +000030// and the shading language compiler.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000031//
32
Jamie Madille294bb82014-07-17 14:16:26 -040033template <typename VarT>
Jamie Madilla0a9e122015-09-02 15:54:30 -040034const std::vector<VarT> *GetVariableList(const TCompiler *compiler);
Jamie Madille294bb82014-07-17 14:16:26 -040035
36template <>
Jamie Madilla0a9e122015-09-02 15:54:30 -040037const std::vector<sh::Uniform> *GetVariableList(const TCompiler *compiler)
Jamie Madille294bb82014-07-17 14:16:26 -040038{
39 return &compiler->getUniforms();
40}
41
42template <>
Jamie Madilla0a9e122015-09-02 15:54:30 -040043const std::vector<sh::Varying> *GetVariableList(const TCompiler *compiler)
Jamie Madille294bb82014-07-17 14:16:26 -040044{
45 return &compiler->getVaryings();
46}
47
48template <>
Jamie Madilla0a9e122015-09-02 15:54:30 -040049const std::vector<sh::Attribute> *GetVariableList(const TCompiler *compiler)
Jamie Madille294bb82014-07-17 14:16:26 -040050{
Jamie Madilla0a9e122015-09-02 15:54:30 -040051 return &compiler->getAttributes();
Jamie Madille294bb82014-07-17 14:16:26 -040052}
53
54template <>
Jamie Madilla0a9e122015-09-02 15:54:30 -040055const std::vector<sh::OutputVariable> *GetVariableList(const TCompiler *compiler)
56{
57 return &compiler->getOutputVariables();
58}
59
60template <>
61const std::vector<sh::InterfaceBlock> *GetVariableList(const TCompiler *compiler)
Jamie Madille294bb82014-07-17 14:16:26 -040062{
63 return &compiler->getInterfaceBlocks();
64}
65
66template <typename VarT>
Jamie Madilla0a9e122015-09-02 15:54:30 -040067const std::vector<VarT> *GetShaderVariables(const ShHandle handle)
Jamie Madille294bb82014-07-17 14:16:26 -040068{
69 if (!handle)
70 {
71 return NULL;
72 }
73
74 TShHandleBase* base = static_cast<TShHandleBase*>(handle);
75 TCompiler* compiler = base->getAsCompiler();
76 if (!compiler)
77 {
78 return NULL;
79 }
80
Jamie Madilla0a9e122015-09-02 15:54:30 -040081 return GetVariableList<VarT>(compiler);
Jamie Madille294bb82014-07-17 14:16:26 -040082}
83
Zhenyao Mo4de44cb2014-10-29 18:03:46 -070084TCompiler *GetCompilerFromHandle(ShHandle handle)
85{
86 if (!handle)
87 return NULL;
88 TShHandleBase *base = static_cast<TShHandleBase *>(handle);
89 return base->getAsCompiler();
Jamie Madille294bb82014-07-17 14:16:26 -040090}
91
Daniel Bratell73941de2015-02-25 14:34:49 +010092#ifdef ANGLE_ENABLE_HLSL
Zhenyao Mo4de44cb2014-10-29 18:03:46 -070093TranslatorHLSL *GetTranslatorHLSLFromHandle(ShHandle handle)
94{
95 if (!handle)
96 return NULL;
97 TShHandleBase *base = static_cast<TShHandleBase *>(handle);
98 return base->getAsTranslatorHLSL();
99}
Daniel Bratell73941de2015-02-25 14:34:49 +0100100#endif // ANGLE_ENABLE_HLSL
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700101
Jamie Madilla0a9e122015-09-02 15:54:30 -0400102} // anonymous namespace
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700103
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000104//
Alok Priyadarshib11713f2013-08-01 16:02:39 -0700105// Driver must call this first, once, before doing any other compiler operations.
106// Subsequent calls to this function are no-op.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000107//
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700108bool ShInitialize()
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000109{
Jamie Madill477bc782014-02-26 09:54:17 -0500110 if (!isInitialized)
111 {
112 isInitialized = InitProcess();
113 }
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700114 return isInitialized;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000115}
116
117//
alokp@chromium.org94a86ad2010-08-25 20:02:11 +0000118// Cleanup symbol tables
119//
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700120bool ShFinalize()
alokp@chromium.org94a86ad2010-08-25 20:02:11 +0000121{
Geoff Langf20f0202014-04-28 11:02:07 -0400122 if (isInitialized)
123 {
124 DetachProcess();
125 isInitialized = false;
126 }
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700127 return true;
alokp@chromium.org94a86ad2010-08-25 20:02:11 +0000128}
129
130//
131// Initialize built-in resources with minimum expected values.
132//
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000133void ShInitBuiltInResources(ShBuiltInResources* resources)
alokp@chromium.org94a86ad2010-08-25 20:02:11 +0000134{
Kimmo Kinnunen7c1cfd62014-10-15 14:59:57 +0300135 // Make comparable.
136 memset(resources, 0, sizeof(*resources));
137
alokp@chromium.org94a86ad2010-08-25 20:02:11 +0000138 // Constants.
139 resources->MaxVertexAttribs = 8;
140 resources->MaxVertexUniformVectors = 128;
141 resources->MaxVaryingVectors = 8;
142 resources->MaxVertexTextureImageUnits = 0;
143 resources->MaxCombinedTextureImageUnits = 8;
144 resources->MaxTextureImageUnits = 8;
145 resources->MaxFragmentUniformVectors = 16;
146 resources->MaxDrawBuffers = 1;
147
148 // Extensions.
149 resources->OES_standard_derivatives = 0;
zmo@google.com09c323a2011-08-12 18:22:25 +0000150 resources->OES_EGL_image_external = 0;
Geoff Langb66a9092016-05-16 15:59:14 -0400151 resources->OES_EGL_image_external_essl3 = 0;
152 resources->NV_EGL_stream_consumer_external = 0;
kbr@chromium.org205fef32011-11-22 20:50:02 +0000153 resources->ARB_texture_rectangle = 0;
Kimmo Kinnunenb18609b2015-07-16 14:13:11 +0300154 resources->EXT_blend_func_extended = 0;
shannon.woods@transgaming.com550cd092013-02-28 23:19:54 +0000155 resources->EXT_draw_buffers = 0;
Jamie Madill2aeb26a2013-07-08 14:02:55 -0400156 resources->EXT_frag_depth = 0;
Nicolas Capens46485082014-04-15 13:12:50 -0400157 resources->EXT_shader_texture_lod = 0;
Olli Etuaho853dc1a2014-11-06 17:25:48 +0200158 resources->WEBGL_debug_shader_precision = 0;
Erik Dahlströmea7a2122014-11-17 16:15:57 +0100159 resources->EXT_shader_framebuffer_fetch = 0;
160 resources->NV_shader_framebuffer_fetch = 0;
161 resources->ARM_shader_framebuffer_fetch = 0;
daniel@transgaming.comc23f4612012-11-28 19:42:57 +0000162
Olli Etuahoe61209a2014-09-26 12:01:17 +0300163 resources->NV_draw_buffers = 0;
164
shannon.woods%transgaming.com@gtempaccount.comcbb6b6a2013-04-13 03:27:47 +0000165 // Disable highp precision in fragment shader by default.
166 resources->FragmentPrecisionHigh = 0;
167
shannonwoods@chromium.org74b86cf2013-05-30 00:02:58 +0000168 // GLSL ES 3.0 constants.
169 resources->MaxVertexOutputVectors = 16;
170 resources->MaxFragmentInputVectors = 15;
171 resources->MinProgramTexelOffset = -8;
172 resources->MaxProgramTexelOffset = 7;
173
Kimmo Kinnunenb18609b2015-07-16 14:13:11 +0300174 // Extensions constants.
175 resources->MaxDualSourceDrawBuffers = 0;
176
daniel@transgaming.comc23f4612012-11-28 19:42:57 +0000177 // Disable name hashing by default.
178 resources->HashFunction = NULL;
shannon.woods@transgaming.com1d432bb2013-01-25 21:57:28 +0000179
180 resources->ArrayIndexClampingStrategy = SH_CLAMP_WITH_CLAMP_INTRINSIC;
Nicolas Capens7d649a02014-02-07 11:24:32 -0500181
182 resources->MaxExpressionComplexity = 256;
Olli Etuaho19d1dc92016-03-08 17:18:46 +0200183 resources->MaxCallStackDepth = 256;
184 resources->MaxFunctionParameters = 1024;
Martin Radeve93d24e2016-07-28 12:06:05 +0300185
186 // ES 3.1 Revision 4, 7.2 Built-in Constants
187 resources->MaxImageUnits = 4;
188 resources->MaxVertexImageUniforms = 0;
189 resources->MaxFragmentImageUniforms = 0;
190 resources->MaxComputeImageUniforms = 4;
191 resources->MaxCombinedImageUniforms = 4;
192
193 resources->MaxCombinedShaderOutputResources = 4;
194
195 resources->MaxComputeWorkGroupCount[0] = 65535;
196 resources->MaxComputeWorkGroupCount[1] = 65535;
197 resources->MaxComputeWorkGroupCount[2] = 65535;
198 resources->MaxComputeWorkGroupSize[0] = 128;
199 resources->MaxComputeWorkGroupSize[1] = 128;
200 resources->MaxComputeWorkGroupSize[2] = 64;
201 resources->MaxComputeUniformComponents = 512;
202 resources->MaxComputeTextureImageUnits = 16;
203
204 resources->MaxComputeAtomicCounters = 8;
205 resources->MaxComputeAtomicCounterBuffers = 1;
206
207 resources->MaxVertexAtomicCounters = 0;
208 resources->MaxFragmentAtomicCounters = 0;
209 resources->MaxCombinedAtomicCounters = 8;
210 resources->MaxAtomicCounterBindings = 1;
211
212 resources->MaxVertexAtomicCounterBuffers = 0;
213 resources->MaxFragmentAtomicCounterBuffers = 0;
214 resources->MaxCombinedAtomicCounterBuffers = 1;
215 resources->MaxAtomicCounterBufferSize = 32;
alokp@chromium.org94a86ad2010-08-25 20:02:11 +0000216}
217
218//
alokp@chromium.org774d7062010-07-21 18:55:45 +0000219// Driver calls these to create and destroy compiler objects.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000220//
Jamie Madill183bde52014-07-02 15:31:19 -0400221ShHandle ShConstructCompiler(sh::GLenum type, ShShaderSpec spec,
zmo@google.com5601ea02011-06-10 18:23:25 +0000222 ShShaderOutput output,
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000223 const ShBuiltInResources* resources)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000224{
zmo@google.com5601ea02011-06-10 18:23:25 +0000225 TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(type, spec, output));
Corentin Wallez700ad282015-12-07 15:57:47 -0500226 if (base == nullptr)
227 {
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000228 return 0;
Corentin Wallez700ad282015-12-07 15:57:47 -0500229 }
230
231 TCompiler* compiler = base->getAsCompiler();
232 if (compiler == nullptr)
233 {
234 return 0;
235 }
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000236
237 // Generate built-in symbol table.
alokp@chromium.org07620a52010-09-23 17:53:56 +0000238 if (!compiler->Init(*resources)) {
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000239 ShDestruct(base);
240 return 0;
241 }
242
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000243 return reinterpret_cast<void*>(base);
244}
245
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000246void ShDestruct(ShHandle handle)
247{
248 if (handle == 0)
249 return;
250
251 TShHandleBase* base = static_cast<TShHandleBase*>(handle);
252
253 if (base->getAsCompiler())
254 DeleteCompiler(base->getAsCompiler());
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000255}
256
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700257const std::string &ShGetBuiltInResourcesString(const ShHandle handle)
Shannon Woods2d76e5f2014-05-16 17:46:41 -0400258{
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700259 TCompiler *compiler = GetCompilerFromHandle(handle);
260 ASSERT(compiler);
261 return compiler->getBuiltInResourcesString();
Shannon Woods2d76e5f2014-05-16 17:46:41 -0400262}
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700263
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000264//
Shannon Woods2d76e5f2014-05-16 17:46:41 -0400265// Do an actual compile on the given strings. The result is left
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000266// in the given compile object.
267//
268// Return: The return value of ShCompile is really boolean, indicating
269// success or failure.
270//
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700271bool ShCompile(
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000272 const ShHandle handle,
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700273 const char *const shaderStrings[],
shannon.woods@transgaming.comd64b3da2013-02-28 23:19:26 +0000274 size_t numStrings,
alokp@chromium.org7beea402010-09-15 21:18:34 +0000275 int compileOptions)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000276{
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700277 TCompiler *compiler = GetCompilerFromHandle(handle);
278 ASSERT(compiler);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000279
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700280 return compiler->compile(shaderStrings, numStrings, compileOptions);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000281}
282
Dmitry Skiba2539fff2015-06-16 17:56:09 -0700283void ShClearResults(const ShHandle handle)
284{
285 TCompiler *compiler = GetCompilerFromHandle(handle);
286 ASSERT(compiler);
287 compiler->clearResults();
288}
289
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700290int ShGetShaderVersion(const ShHandle handle)
alokp@chromium.org7beea402010-09-15 21:18:34 +0000291{
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700292 TCompiler* compiler = GetCompilerFromHandle(handle);
293 ASSERT(compiler);
294 return compiler->getShaderVersion();
295}
alokp@chromium.org7beea402010-09-15 21:18:34 +0000296
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700297ShShaderOutput ShGetShaderOutputType(const ShHandle handle)
298{
299 TCompiler* compiler = GetCompilerFromHandle(handle);
300 ASSERT(compiler);
301 return compiler->getOutputType();
alokp@chromium.org7beea402010-09-15 21:18:34 +0000302}
303
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000304//
alokp@chromium.org774d7062010-07-21 18:55:45 +0000305// Return any compiler log of messages for the application.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000306//
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700307const std::string &ShGetInfoLog(const ShHandle handle)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000308{
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700309 TCompiler *compiler = GetCompilerFromHandle(handle);
310 ASSERT(compiler);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000311
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700312 TInfoSink &infoSink = compiler->getInfoSink();
313 return infoSink.info.str();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000314}
315
316//
alokp@chromium.org774d7062010-07-21 18:55:45 +0000317// Return any object code.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000318//
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700319const std::string &ShGetObjectCode(const ShHandle handle)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000320{
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700321 TCompiler *compiler = GetCompilerFromHandle(handle);
322 ASSERT(compiler);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000323
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700324 TInfoSink &infoSink = compiler->getInfoSink();
325 return infoSink.obj.str();
alokp@chromium.org7beea402010-09-15 21:18:34 +0000326}
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000327
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700328const std::map<std::string, std::string> *ShGetNameHashingMap(
329 const ShHandle handle)
daniel@transgaming.comc23f4612012-11-28 19:42:57 +0000330{
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700331 TCompiler *compiler = GetCompilerFromHandle(handle);
332 ASSERT(compiler);
333 return &(compiler->getNameMap());
daniel@transgaming.comc23f4612012-11-28 19:42:57 +0000334}
daniel@transgaming.com043da132012-12-20 21:12:22 +0000335
Jamie Madille294bb82014-07-17 14:16:26 -0400336const std::vector<sh::Uniform> *ShGetUniforms(const ShHandle handle)
daniel@transgaming.com043da132012-12-20 21:12:22 +0000337{
Jamie Madilla0a9e122015-09-02 15:54:30 -0400338 return GetShaderVariables<sh::Uniform>(handle);
Jamie Madille294bb82014-07-17 14:16:26 -0400339}
daniel@transgaming.com043da132012-12-20 21:12:22 +0000340
Jamie Madille294bb82014-07-17 14:16:26 -0400341const std::vector<sh::Varying> *ShGetVaryings(const ShHandle handle)
342{
Jamie Madilla0a9e122015-09-02 15:54:30 -0400343 return GetShaderVariables<sh::Varying>(handle);
Jamie Madille294bb82014-07-17 14:16:26 -0400344}
daniel@transgaming.com043da132012-12-20 21:12:22 +0000345
Jamie Madille294bb82014-07-17 14:16:26 -0400346const std::vector<sh::Attribute> *ShGetAttributes(const ShHandle handle)
347{
Jamie Madilla0a9e122015-09-02 15:54:30 -0400348 return GetShaderVariables<sh::Attribute>(handle);
Jamie Madille294bb82014-07-17 14:16:26 -0400349}
350
Jamie Madilla0a9e122015-09-02 15:54:30 -0400351const std::vector<sh::OutputVariable> *ShGetOutputVariables(const ShHandle handle)
Jamie Madille294bb82014-07-17 14:16:26 -0400352{
Jamie Madilla0a9e122015-09-02 15:54:30 -0400353 return GetShaderVariables<sh::OutputVariable>(handle);
Jamie Madille294bb82014-07-17 14:16:26 -0400354}
355
356const std::vector<sh::InterfaceBlock> *ShGetInterfaceBlocks(const ShHandle handle)
357{
Jamie Madilla0a9e122015-09-02 15:54:30 -0400358 return GetShaderVariables<sh::InterfaceBlock>(handle);
shannon.woods@transgaming.com1d432bb2013-01-25 21:57:28 +0000359}
Zhenyao Moa15f3e82013-09-23 14:57:08 -0400360
Martin Radev4c4c8e72016-08-04 12:25:34 +0300361sh::WorkGroupSize ShGetComputeShaderLocalGroupSize(const ShHandle handle)
Martin Radev802abe02016-08-04 17:48:32 +0300362{
363 ASSERT(handle);
364
365 TShHandleBase *base = static_cast<TShHandleBase *>(handle);
366 TCompiler *compiler = base->getAsCompiler();
367 ASSERT(compiler);
368
369 return compiler->getComputeShaderLocalSize();
370}
371
Corentin Walleze58e1412016-07-18 16:40:46 -0400372bool ShCheckVariablesWithinPackingLimits(int maxVectors,
373 const std::vector<sh::ShaderVariable> &variables)
374{
Zhenyao Moa15f3e82013-09-23 14:57:08 -0400375 VariablePacker packer;
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700376 return packer.CheckVariablesWithinPackingLimits(maxVectors, variables);
Zhenyao Moa15f3e82013-09-23 14:57:08 -0400377}
Jamie Madill4e1fd412014-07-10 17:50:10 -0400378
379bool ShGetInterfaceBlockRegister(const ShHandle handle,
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700380 const std::string &interfaceBlockName,
Jamie Madill4e1fd412014-07-10 17:50:10 -0400381 unsigned int *indexOut)
382{
Daniel Bratell73941de2015-02-25 14:34:49 +0100383#ifdef ANGLE_ENABLE_HLSL
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700384 ASSERT(indexOut);
Jamie Madill4e1fd412014-07-10 17:50:10 -0400385
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700386 TranslatorHLSL *translator = GetTranslatorHLSLFromHandle(handle);
387 ASSERT(translator);
Jamie Madill4e1fd412014-07-10 17:50:10 -0400388
389 if (!translator->hasInterfaceBlock(interfaceBlockName))
390 {
391 return false;
392 }
393
394 *indexOut = translator->getInterfaceBlockRegister(interfaceBlockName);
395 return true;
Daniel Bratell73941de2015-02-25 14:34:49 +0100396#else
397 return false;
398#endif // ANGLE_ENABLE_HLSL
Jamie Madill4e1fd412014-07-10 17:50:10 -0400399}
Jamie Madill9fe25e92014-07-18 10:33:08 -0400400
Olli Etuaho96963162016-03-21 11:54:33 +0200401const std::map<std::string, unsigned int> *ShGetUniformRegisterMap(const ShHandle handle)
Jamie Madill9fe25e92014-07-18 10:33:08 -0400402{
Daniel Bratell73941de2015-02-25 14:34:49 +0100403#ifdef ANGLE_ENABLE_HLSL
Zhenyao Mo4de44cb2014-10-29 18:03:46 -0700404 TranslatorHLSL *translator = GetTranslatorHLSLFromHandle(handle);
405 ASSERT(translator);
Jamie Madill9fe25e92014-07-18 10:33:08 -0400406
Olli Etuaho96963162016-03-21 11:54:33 +0200407 return translator->getUniformRegisterMap();
Daniel Bratell73941de2015-02-25 14:34:49 +0100408#else
Olli Etuaho96963162016-03-21 11:54:33 +0200409 static std::map<std::string, unsigned int> map;
410 return &map;
411#endif // ANGLE_ENABLE_HLSL
Corentin Walleze58e1412016-07-18 16:40:46 -0400412}