Skip to content

Instantly share code, notes, and snippets.

@darksylinc
Created January 24, 2022 23:36
Show Gist options
  • Save darksylinc/655495dae603c4e544dd475ae3537621 to your computer and use it in GitHub Desktop.
Save darksylinc/655495dae603c4e544dd475ae3537621 to your computer and use it in GitHub Desktop.
FXC broken
// Compiling this code with:
// fxc.exe /T ps_5_0 /O0 /E main broken_min16float.hlsl
// Will result in the following:
// error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: Incompatible min precision type for operand #1 of opcode #6 (counts are 1-based). Expected int or uint.
//
// Works if compiled with Od for no optimizations
#define _h( x ) min16float( ( x ) )
cbuffer PassBuffer : register( b0 )
{
float param0;
}
min16float BRDF_AreaLightApprox( min16float a, min16float b )
{
return b * a;
}
float4 main() : SV_Target0
{
min16float specular = min16float( 1 );
min16float booster = _h( 4.0f );
min16float specCol = _h( 0.0 );
if( param0 > 0 )
{
if( param0 >= 0 )
{
specCol = _h( 0.5f );
}
}
min16float3 tmpColour;
tmpColour = BRDF_AreaLightApprox( specCol.x, specular );
tmpColour *= booster;
float4 outPs;
outPs.xyz = tmpColour;
outPs.w = _h( 1.0 );
return outPs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment