summaryrefslogtreecommitdiff
path: root/source/slang/compiler.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-07-12 11:07:45 -0700
committerTim Foley <tfoley@nvidia.com>2017-07-12 11:07:45 -0700
commit74963469a169b49d61196e3a3b33a903ea8bfede (patch)
treea3d8f4f8873946f58111ae5e7f5034b071c1e824 /source/slang/compiler.cpp
parent2c6c501b36db9e7991c3f7999451b70f12329ecc (diff)
Add basic reflection query for checking if entry point is "sample-rate"
- This really just checks two basic things: 1. Was there any global variable declared with `in` and `sample`? 2. Did any code encountered during lowering referenece `gl_SampleIndex`? - This doesn't cover what HLSL could need, nor what we would need for cross-compilation. Consider it GLSL-specific for now. - In order to generate the information with even a reasonable chance of being accurate (not giving a ton of false positives) I tried to integrate the checks into the lowering process (so they only see code that is referenced, one hopes). - For this to work with my testing setup, I needed to make sure that lowering is always performed, prior to emitting reflection info - This change broke several reflection tests, because they had been using code that wouldn't actually pass the downstream compiler. I checked in fixes for those.
Diffstat (limited to 'source/slang/compiler.cpp')
-rw-r--r--source/slang/compiler.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/source/slang/compiler.cpp b/source/slang/compiler.cpp
index 3155bb75a..7df978707 100644
--- a/source/slang/compiler.cpp
+++ b/source/slang/compiler.cpp
@@ -565,13 +565,31 @@ namespace Slang
void generateOutput(
CompileRequest* compileRequest)
{
- // Allow for an "extra" target to verride things first.
+ // Start of with per-translation-unit and per-entry-point lowering
+ for( auto translationUnit : compileRequest->translationUnits )
+ {
+ CompileResult translationUnitResult = emitTranslationUnit(translationUnit.Ptr());
+ translationUnit->result = translationUnitResult;
+ }
+
+
+ // Allow for an "extra" target to verride things before we finish.
switch (compileRequest->extraTarget)
{
case CodeGenTarget::ReflectionJSON:
{
String reflectionJSON = emitReflectionJSON(compileRequest->layout.Ptr());
+ // Clobber existing output so we don't have to deal with it
+ for( auto translationUnit : compileRequest->translationUnits )
+ {
+ translationUnit->result = CompileResult();
+ }
+ for( auto entryPoint : compileRequest->entryPoints )
+ {
+ entryPoint->result = CompileResult();
+ }
+
// HACK(tfoley): just print it out since that is what people probably expect.
// TODO: need a way to control where output gets routed across all possible targets.
fprintf(stdout, "%s", reflectionJSON.begin());
@@ -584,12 +602,6 @@ namespace Slang
break;
}
- // For most targets, we will do things per-translation-unit
- for( auto translationUnit : compileRequest->translationUnits )
- {
- CompileResult translationUnitResult = emitTranslationUnit(translationUnit.Ptr());
- translationUnit->result = translationUnitResult;
- }
}
}