diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2018-10-04 10:25:36 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-04 10:25:36 -0400 |
| commit | 84a48475067af70c9acccc9816dd60e623714328 (patch) | |
| tree | ecb4fbc2932a3a5771a0240af367c7712f5fc620 | |
| parent | eaafafe772366a23ed847cbb10770c72aa5cfc28 (diff) | |
Remove need of IRHightLevelDecoration in emit (#660)
* * Remove the need for IRHighLevelDecoration in Emit
* Use the IRLayoutDecoration for GeometryShaderPrimitiveTypeModifier
* Fixing problems with comparison due to naming differences with slang/fxc.
| -rw-r--r-- | source/slang/emit.cpp | 42 | ||||
| -rw-r--r-- | tests/hlsl/dxsdk/FluidCS11/FluidRender.hlsl | 26 |
2 files changed, 47 insertions, 21 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 1b527c01f..521a9fe1f 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -4654,36 +4654,50 @@ struct EmitVisitor emitIREntryPointAttributes(func, ctx, entryPointLayout); } + const CodeGenTarget target = ctx->shared->target; + auto name = getIRFuncName(func); EmitType(resultType, name); emit("("); auto firstParam = func->getFirstParam(); - for( auto pp = firstParam; pp; pp = pp->getNextParam() ) + for( auto pp = firstParam; pp; pp = pp->getNextParam()) { if(pp != firstParam) emit(", "); auto paramName = getIRName(pp); auto paramType = pp->getDataType(); - if (auto decor = pp->findDecoration<IRHighLevelDeclDecoration>()) + + if (target == CodeGenTarget::HLSL) { - if (decor->decl) + if (auto layoutDecor = pp->findDecoration<IRLayoutDecoration>()) { - auto primType = decor->decl->FindModifier<HLSLGeometryShaderInputPrimitiveTypeModifier>(); - if (dynamic_cast<HLSLTriangleModifier*>(primType)) - emit("triangle "); - else if (dynamic_cast<HLSLPointModifier*>(primType)) - emit("point "); - else if (dynamic_cast<HLSLLineModifier*>(primType)) - emit("line "); - else if (dynamic_cast<HLSLLineAdjModifier*>(primType)) - emit("lineadj "); - else if (dynamic_cast<HLSLTriangleAdjModifier*>(primType)) - emit("triangleadj "); + Layout* layout = layoutDecor->layout; + VarLayout* varLayout = dynamic_cast<VarLayout*>(layout); + + if (varLayout) + { + auto var = varLayout->getVariable(); + + if (auto primTypeModifier = var->FindModifier<HLSLGeometryShaderInputPrimitiveTypeModifier>()) + { + if (dynamic_cast<HLSLTriangleModifier*>(primTypeModifier)) + emit("triangle "); + else if (dynamic_cast<HLSLPointModifier*>(primTypeModifier)) + emit("point "); + else if (dynamic_cast<HLSLLineModifier*>(primTypeModifier)) + emit("line "); + else if (dynamic_cast<HLSLLineAdjModifier*>(primTypeModifier)) + emit("lineadj "); + else if (dynamic_cast<HLSLTriangleAdjModifier*>(primTypeModifier)) + emit("triangleadj "); + } + } } } + emitIRParamType(ctx, paramType, paramName); emitIRSemantics(ctx, pp); diff --git a/tests/hlsl/dxsdk/FluidCS11/FluidRender.hlsl b/tests/hlsl/dxsdk/FluidCS11/FluidRender.hlsl index cf1e7c227..496240dc9 100644 --- a/tests/hlsl/dxsdk/FluidCS11/FluidRender.hlsl +++ b/tests/hlsl/dxsdk/FluidCS11/FluidRender.hlsl @@ -1,5 +1,17 @@ -//TEST_IGNORE_FILE: Currently failing due to Slang compiler issues. -//TEST:COMPARE_HLSL: -target dxbc-assembly -profile vs_4_0 -entry ParticleVS -profile gs_4_0 -entry ParticleGS -profile ps_4_0 -entry ParticlePS +//TEST:COMPARE_HLSL:-no-mangle -target dxbc-assembly -profile vs_4_0 -entry ParticleVS -profile gs_4_0 -entry ParticleGS -profile ps_4_0 -entry ParticlePS + +#ifndef __SLANG__ +#define ParticlesRO ParticlesRO_0 +#define ParticleDensityRO ParticleDensityRO_0 +#define cbRenderConstants cbRenderConstants_0 +#define g_mViewProjection g_mViewProjection_0 +#define g_fParticleSize g_fParticleSize_0 +#define density density_0 +#define position position_0 +#define velocity velocity_0 + +#endif + //-------------------------------------------------------------------------------------- // File: FluidRender.hlsl // @@ -56,7 +68,7 @@ static const float4 Rainbow[5] = { float4 VisualizeNumber(float n) { - return lerp( Rainbow[ floor(n * 4.0f) ], Rainbow[ ceil(n * 4.0f) ], frac(n * 4.0f) ); + return lerp( Rainbow[ int(floor(n * 4.0f)) ], Rainbow[ int(ceil(n * 4.0f)) ], frac(n * 4.0f) ); } float4 VisualizeNumber(float n, float lower, float upper) @@ -69,9 +81,9 @@ float4 VisualizeNumber(float n, float lower, float upper) // Vertex Shader //-------------------------------------------------------------------------------------- -VSParticleOut ParticleVS(uint ID : SV_VertexID) +VSParticleOut ParticleVS(uint ID : SV_VERTEXID) { - VSParticleOut Out = (VSParticleOut)0; + VSParticleOut Out; // = { { 0, 0 } , { 0, 0, 0, 0 } }; // (VSParticleOut)0; Out.position = ParticlesRO[ID].position; Out.color = VisualizeNumber(ParticleDensityRO[ID].density, 1000.0f, 2000.0f); return Out; @@ -91,7 +103,7 @@ void ParticleGS(point VSParticleOut In[1], inout TriangleStream<GSParticleOut> S [unroll] for (int i = 0; i < 4; i++) { - GSParticleOut Out = (GSParticleOut)0; + GSParticleOut Out; // = (GSParticleOut)0; float4 position = float4(In[0].position, 0, 1) + g_fParticleSize * float4(g_positions[i], 0, 0); Out.position = mul(position, g_mViewProjection); Out.color = In[0].color; @@ -106,7 +118,7 @@ void ParticleGS(point VSParticleOut In[1], inout TriangleStream<GSParticleOut> S // Pixel Shader //-------------------------------------------------------------------------------------- -float4 ParticlePS(GSParticleOut In) : SV_Target +float4 ParticlePS(GSParticleOut In) : SV_TARGET { return In.color; } |
