diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2017-07-10 09:49:46 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-10 09:49:46 -0700 |
| commit | 8abdf2dddd10feb9794c86cdf6b2159a2b6383e4 (patch) | |
| tree | df7d790f33f7e4c8adc1b9b747c7c908d8bab0d4 /source/slang/slang-stdlib.cpp | |
| parent | 68df74b58a56b0a1fb19b9ec4ff0282969cd6a12 (diff) | |
| parent | 5b7c254d24653fd1c19157e8d5ef68a7e787ff58 (diff) | |
Merge pull request #65 from tfoleyNV/falcor-work
Falcor work
Diffstat (limited to 'source/slang/slang-stdlib.cpp')
| -rw-r--r-- | source/slang/slang-stdlib.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/slang/slang-stdlib.cpp b/source/slang/slang-stdlib.cpp index e2d5829b4..23d66201a 100644 --- a/source/slang/slang-stdlib.cpp +++ b/source/slang/slang-stdlib.cpp @@ -1431,6 +1431,22 @@ namespace Slang { int loadCoordCount = kBaseTextureTypes[tt].coordCount + isArray + (isMultisample?0:1); + // When translating to GLSL, we need to break apart the `location` argument. + // + // TODO: this should realy be handled by having this member actually get lowered! + int glslLoadCoordCount = kBaseTextureTypes[tt].coordCount + isArray; + static const char* kGLSLLoadCoordsSwizzle[] = { "", "", "x", "xy", "xyz", "xyzw" }; + static const char* kGLSLLoadLODSwizzle[] = { "", "", "y", "z", "w", "error" }; + + if (isMultisample) + { + sb << "__intrinsic(glsl, \"texelFetch($P, $0, $1)\")\n"; + } + else + { + sb << "__intrinsic(glsl, \"texelFetch($P, ($0)." << kGLSLLoadCoordsSwizzle[loadCoordCount] << ", ($0)." << kGLSLLoadLODSwizzle[loadCoordCount] << ")\")\n"; + } + sb << "__intrinsic\n"; sb << "T Load("; sb << "int" << loadCoordCount << " location"; if(isMultisample) @@ -1439,6 +1455,15 @@ namespace Slang } sb << ");\n"; + if (isMultisample) + { + sb << "__intrinsic(glsl, \"texelFetchOffset($P, $0, $1, $2)\")\n"; + } + else + { + sb << "__intrinsic(glsl, \"texelFetch($P, ($0)." << kGLSLLoadCoordsSwizzle[loadCoordCount] << ", ($0)." << kGLSLLoadLODSwizzle[loadCoordCount] << ", $1)\")\n"; + } + sb << "__intrinsic\n"; sb << "T Load("; sb << "int" << loadCoordCount << " location"; if(isMultisample) @@ -1470,11 +1495,15 @@ namespace Slang { // `Sample()` + sb << "__intrinsic(glsl, \"texture($p, $1)\")\n"; + sb << "__intrinsic\n"; sb << "T Sample(SamplerState s, "; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location);\n"; if( baseShape != TextureType::ShapeCube ) { + sb << "__intrinsic(glsl, \"textureOffset($p, $1)\")\n"; + sb << "__intrinsic\n"; sb << "T Sample(SamplerState s, "; sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, "; sb << "int" << kBaseTextureTypes[tt].coordCount << " offset);\n"; |
