D3DXAssembleShader function was used in DirectX 9 for compiling shaders from Assembly. It's not supported in DirectX 11. Is there any alternative to create shaders from Assembler code?
I am aware of compiling from fx or hlsl files but for my project purposes, I should compile only using assembly.
The following code was used in DirectX 9:
static const char VertexShaderCode[] = \
"vs.3.0\n"
"dcl_position v0\n"
"dcl_position o0\n"
"mov o0, v0\n";
D3DXAssembleShader(VertexShaderCode,sizeof(VertexShaderCode), 0,0, DLL, &VSBuffer, 0);
I am looking for an alternative to the above code in DirectX11 using D3D11 dll's.
I want to modify my asm file like below and create vertex and pixel shaders:
dcl_output o0.xyzw -> dcl_output.o0.zw
Will I be able to do the same in fx or hlsl file?
FX file:
cbuffer ConstantBuffer : register( b0 )
{
matrix World;
matrix View;
matrix Projection;
}
//--------------------------------------------------------------------------------------
struct VS_OUTPUT
{
float4 Pos : SV_POSITION;
float4 Color : COLOR0;
};
//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
VS_OUTPUT VS( float4 Pos : POSITION, float4 Color : COLOR )
{
VS_OUTPUT output = (VS_OUTPUT)0;
output.Pos = mul( Pos, World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );
output.Color = Color;
return output;
}
//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 PS( VS_OUTPUT input ) : SV_Target
{
return input.Color;
}
Compiling from HLSL shader assembly isn't officially supported for Shader Model 4.0, 4.1, 5.0, or 5.1.
When you build with
fxc.exe
you get disassembly for debugging & optimization purposes
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.