summaryrefslogtreecommitdiff
path: root/source/slang/core.meta.slang
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-03-27 12:25:43 -0400
committerGitHub <noreply@github.com>2019-03-27 12:25:43 -0400
commitc9930ea56ce0d3d9783d4d2482edb91cb765109e (patch)
tree42bc3b4d44771d1c1bca389f20b9321793d268e1 /source/slang/core.meta.slang
parent047adbd4dd3dd6e3098adcb63a8ac475ae06d20d (diff)
GLSL half texture access (#931)
* * Added $c macro - that will do casting to target type. Used here to cast texture reads back to half. Works in tandem with $z which will close parens. * half-texture.slang test * Make binding failing if TextureView fails * Simplify logic around parens. * Improve comment around $c macro. * Test against hlsl output to avoid error on CI.
Diffstat (limited to 'source/slang/core.meta.slang')
-rw-r--r--source/slang/core.meta.slang32
1 files changed, 16 insertions, 16 deletions
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang
index e42669822..dc7d1f3fb 100644
--- a/source/slang/core.meta.slang
+++ b/source/slang/core.meta.slang
@@ -703,12 +703,12 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
if (isMultisample)
{
sb << "__glsl_extension(GL_EXT_samplerless_texture_functions)";
- sb << "__target_intrinsic(glsl, \"texelFetch($0, $1, $3)$z\")\n";
+ sb << "__target_intrinsic(glsl, \"$ctexelFetch($0, $1, $3)$z\")\n";
}
else
{
sb << "__glsl_extension(GL_EXT_samplerless_texture_functions)";
- sb << "__target_intrinsic(glsl, \"texelFetch($0, ";
+ sb << "__target_intrinsic(glsl, \"$ctexelFetch($0, ";
if( needsMipLevel )
{
sb << "($1)." << kGLSLLoadCoordsSwizzle[loadCoordCount] << ", ($1)." << kGLSLLoadLODSwizzle[loadCoordCount];
@@ -730,12 +730,12 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
if (isMultisample)
{
sb << "__glsl_extension(GL_EXT_samplerless_texture_functions)";
- sb << "__target_intrinsic(glsl, \"texelFetchOffset($0, $0, $1, $2)$z\")\n";
+ sb << "__target_intrinsic(glsl, \"$ctexelFetchOffset($0, $0, $1, $2)$z\")\n";
}
else
{
sb << "__glsl_extension(GL_EXT_samplerless_texture_functions)";
- sb << "__target_intrinsic(glsl, \"texelFetch($0, ";
+ sb << "__target_intrinsic(glsl, \"$ctexelFetch($0, ";
if( needsMipLevel )
{
sb << "($1)." << kGLSLLoadCoordsSwizzle[loadCoordCount] << ", ($1)." << kGLSLLoadLODSwizzle[loadCoordCount];
@@ -786,7 +786,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
case SLANG_RESOURCE_ACCESS_NONE:
case SLANG_RESOURCE_ACCESS_READ:
sb << "__glsl_extension(GL_EXT_samplerless_texture_functions)";
- sb << "__target_intrinsic(glsl, \"texelFetch($0, " << ivecN << "($1)";
+ sb << "__target_intrinsic(glsl, \"$ctexelFetch($0, " << ivecN << "($1)";
if( !isMultisample )
{
sb << ", 0";
@@ -799,7 +799,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
break;
default:
- sb << "__target_intrinsic(glsl, \"imageLoad($0, " << ivecN << "($1)";
+ sb << "__target_intrinsic(glsl, \"$cimageLoad($0, " << ivecN << "($1)";
if( isMultisample )
{
// TODO: how to handle passing through sample index?
@@ -834,13 +834,13 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
{
// `Sample()`
- sb << "__target_intrinsic(glsl, \"texture($p, $2)$z\")\n";
+ sb << "__target_intrinsic(glsl, \"$ctexture($p, $2)$z\")\n";
sb << "T Sample(SamplerState s, ";
sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location);\n";
if( baseShape != TextureFlavor::Shape::ShapeCube )
{
- sb << "__target_intrinsic(glsl, \"textureOffset($p, $2, $3)$z\")\n";
+ sb << "__target_intrinsic(glsl, \"$ctextureOffset($p, $2, $3)$z\")\n";
sb << "T Sample(SamplerState s, ";
sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, ";
sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset);\n";
@@ -864,13 +864,13 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
// `SampleBias()`
- sb << "__target_intrinsic(glsl, \"texture($p, $2, $3)$z\")\n";
+ sb << "__target_intrinsic(glsl, \"$ctexture($p, $2, $3)$z\")\n";
sb << "T SampleBias(SamplerState s, ";
sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, float bias);\n";
if( baseShape != TextureFlavor::Shape::ShapeCube )
{
- sb << "__target_intrinsic(glsl, \"textureOffset($p, $2, $3, $4)$z\")\n";
+ sb << "__target_intrinsic(glsl, \"$ctextureOffset($p, $2, $3, $4)$z\")\n";
sb << "T SampleBias(SamplerState s, ";
sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, float bias, ";
sb << "constexpr int" << kBaseTextureTypes[tt].coordCount << " offset);\n";
@@ -898,7 +898,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
if (extCoordCount < 3)
extCoordCount = 3;
- sb << "__target_intrinsic(glsl, \"textureLod($p, ";
+ sb << "__target_intrinsic(glsl, \"$ctextureLod($p, ";
sb << "vec" << extCoordCount << "($2,";
for (int ii = arrCoordCount; ii < extCoordCount - 1; ++ii)
@@ -916,7 +916,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
if (extCoordCount < 3)
extCoordCount = 3;
- sb << "__target_intrinsic(glsl, \"textureGrad($p, ";
+ sb << "__target_intrinsic(glsl, \"$ctextureGrad($p, ";
sb << "vec" << extCoordCount << "($2,";
for (int ii = arrCoordCount; ii < extCoordCount - 1; ++ii)
@@ -953,7 +953,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
}
- sb << "__target_intrinsic(glsl, \"textureGrad($p, $2, $3, $4)$z\")\n";
+ sb << "__target_intrinsic(glsl, \"$ctextureGrad($p, $2, $3, $4)$z\")\n";
// sb << "__intrinsic_op(sampleGrad)\n";
sb << "T SampleGrad(SamplerState s, ";
sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, ";
@@ -963,7 +963,7 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
if( baseShape != TextureFlavor::Shape::ShapeCube )
{
- sb << "__target_intrinsic(glsl, \"textureGradOffset($p, $2, $3, $4, $5)$z\")\n";
+ sb << "__target_intrinsic(glsl, \"$ctextureGradOffset($p, $2, $3, $4, $5)$z\")\n";
// sb << "__intrinsic_op(sampleGrad)\n";
sb << "T SampleGrad(SamplerState s, ";
sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, ";
@@ -974,14 +974,14 @@ for (int tt = 0; tt < kBaseTextureTypeCount; ++tt)
// `SampleLevel`
- sb << "__target_intrinsic(glsl, \"textureLod($p, $2, $3)$z\")\n";
+ sb << "__target_intrinsic(glsl, \"$ctextureLod($p, $2, $3)$z\")\n";
sb << "T SampleLevel(SamplerState s, ";
sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, ";
sb << "float level);\n";
if( baseShape != TextureFlavor::Shape::ShapeCube )
{
- sb << "__target_intrinsic(glsl, \"textureLodOffset($p, $2, $3, $4)$z\")\n";
+ sb << "__target_intrinsic(glsl, \"$ctextureLodOffset($p, $2, $3, $4)$z\")\n";
sb << "T SampleLevel(SamplerState s, ";
sb << "float" << kBaseTextureTypes[tt].coordCount + isArray << " location, ";
sb << "float level, ";