Skip to content

Instantly share code, notes, and snippets.

@vk2gpu
Last active July 21, 2017 11:18
Show Gist options
  • Save vk2gpu/b4a7ca79bc9f0a8e49af0fd49146487c to your computer and use it in GitHub Desktop.
Save vk2gpu/b4a7ca79bc9f0a8e49af0fd49146487c to your computer and use it in GitHub Desktop.
[internal("SamplerState")]
struct SamplerState
{
AddressingMode AddressU;
AddressingMode AddressV;
AddressingMode AddressW;
FilteringMode MinFilter;
FilteringMode MagFilter;
float MipLODBias;
uint MaxAnisotropy;
float BorderColor;//[4];
float MinLOD;
float MaxLOD;
};
[internal("BlendState")]
struct BlendState
{
uint Enable;
BlendType SrcBlend;
BlendType DestBlend;
BlendFunc BlendOp;
BlendType SrcBlendAlpha;
BlendType DestBlendAlpha;
BlendFunc BlendOpAlpha;
uint WriteMask;
};
[internal("StencilFaceState")]
struct StencilFaceState
{
StencilFunc Fail;
StencilFunc DepthFail;
StencilFunc Pass;
CompareMode Func;
};
[internal("RenderState")]
struct RenderState
{
BlendState BlendStates;//[8];
StencilFaceState StencilFront;
StencilFaceState StencilBack;
uint DepthEnable;
uint DepthWriteMask;
CompareMode DepthFunc;
uint StencilEnable;
uint StencilRef;
uint StencilRead;
uint StencilWrite;
FillMode FillMode;
CullMode CullMode;
float DepthBias;
float SlopeScaledDepthBias;
uint AntialiasedLineEnable;
};
[internal("Technique")]
struct Technique
{
[fn("VertexShader")]
void VertexShader;
[fn("GeometryShader")]
void GeometryShader;
[fn("HullShader")]
void HullShader;
[fn("DomainShader")]
void DomainShader;
[fn("PixelShader")]
void PixelShader;
[fn("ComputeShader")]
void ComputeShader;
RenderState RenderState;
};
ShaderFile (00-basic.esf) {
Struct (SamplerState) {
Attribute (internal) {
}
Type (SamplerState) {
Declaration (AddressU) {
TypeIdent (AddressingMode<>) {
}
}
Declaration (AddressV) {
TypeIdent (AddressingMode<>) {
}
}
Declaration (AddressW) {
TypeIdent (AddressingMode<>) {
}
}
Declaration (MinFilter) {
TypeIdent (FilteringMode<>) {
}
}
Declaration (MagFilter) {
TypeIdent (FilteringMode<>) {
}
}
Declaration (MipLODBias) {
TypeIdent (float<>) {
}
}
Declaration (MaxAnisotropy) {
TypeIdent (uint<>) {
}
}
Declaration (BorderColor) {
TypeIdent (float<>) {
}
}
Declaration (MinLOD) {
TypeIdent (float<>) {
}
}
Declaration (MaxLOD) {
TypeIdent (float<>) {
}
}
}
}
Struct (BlendState) {
Attribute (internal) {
}
Type (BlendState) {
Declaration (Enable) {
TypeIdent (uint<>) {
}
}
Declaration (SrcBlend) {
TypeIdent (BlendType<>) {
}
}
Declaration (DestBlend) {
TypeIdent (BlendType<>) {
}
}
Declaration (BlendOp) {
TypeIdent (BlendFunc<>) {
}
}
Declaration (SrcBlendAlpha) {
TypeIdent (BlendType<>) {
}
}
Declaration (DestBlendAlpha) {
TypeIdent (BlendType<>) {
}
}
Declaration (BlendOpAlpha) {
TypeIdent (BlendFunc<>) {
}
}
Declaration (WriteMask) {
TypeIdent (uint<>) {
}
}
}
}
Struct (StencilFaceState) {
Attribute (internal) {
}
Type (StencilFaceState) {
Declaration (Fail) {
TypeIdent (StencilFunc<>) {
}
}
Declaration (DepthFail) {
TypeIdent (StencilFunc<>) {
}
}
Declaration (Pass) {
TypeIdent (StencilFunc<>) {
}
}
Declaration (Func) {
TypeIdent (CompareMode<>) {
}
}
}
}
Struct (RenderState) {
Attribute (internal) {
}
Type (RenderState) {
Declaration (BlendStates) {
TypeIdent (BlendState<>) {
}
}
Declaration (StencilFront) {
TypeIdent (StencilFaceState<>) {
}
}
Declaration (StencilBack) {
TypeIdent (StencilFaceState<>) {
}
}
Declaration (DepthEnable) {
TypeIdent (uint<>) {
}
}
Declaration (DepthWriteMask) {
TypeIdent (uint<>) {
}
}
Declaration (DepthFunc) {
TypeIdent (CompareMode<>) {
}
}
Declaration (StencilEnable) {
TypeIdent (uint<>) {
}
}
Declaration (StencilRef) {
TypeIdent (uint<>) {
}
}
Declaration (StencilRead) {
TypeIdent (uint<>) {
}
}
Declaration (StencilWrite) {
TypeIdent (uint<>) {
}
}
Declaration (FillMode) {
TypeIdent (FillMode<>) {
}
}
Declaration (CullMode) {
TypeIdent (CullMode<>) {
}
}
Declaration (DepthBias) {
TypeIdent (float<>) {
}
}
Declaration (SlopeScaledDepthBias) {
TypeIdent (float<>) {
}
}
Declaration (AntialiasedLineEnable) {
TypeIdent (uint<>) {
}
}
}
}
Struct (Technique) {
Attribute (internal) {
}
Type (Technique) {
Declaration (VertexShader) {
Attribute (fn) {
}
TypeIdent (void<>) {
}
}
Declaration (GeometryShader) {
Attribute (fn) {
}
TypeIdent (void<>) {
}
}
Declaration (HullShader) {
Attribute (fn) {
}
TypeIdent (void<>) {
}
}
Declaration (DomainShader) {
Attribute (fn) {
}
TypeIdent (void<>) {
}
}
Declaration (PixelShader) {
Attribute (fn) {
}
TypeIdent (void<>) {
}
}
Declaration (ComputeShader) {
Attribute (fn) {
}
TypeIdent (void<>) {
}
}
Declaration (RenderState) {
TypeIdent (RenderState<>) {
}
}
}
}
Struct (Test) {
Type (Test) {
Declaration (a) {
TypeIdent (float<>) {
}
}
Declaration (b) {
TypeIdent (float<>) {
}
}
}
}
Struct (VS_IN) {
Attribute (something) {
}
Type (VS_IN) {
Declaration (position_) {
TypeIdent (float3<>) {
}
}
}
}
Struct (VS_OUT) {
Attribute (else) {
}
Type (VS_OUT) {
Declaration (position_) {
TypeIdent (float3<>) {
}
}
}
}
Declaration (Vals) {
TypeIdent (Test<>) {
}
Values () {
MemberValue () { a =
Value () { 0.0
}
}
MemberValue () { b =
Value () { 1.0
}
}
}
}
Declaration (myConstFloat) {
TypeIdent (float<>) {
}
Value () { 1.0
}
}
Declaration (TECH_MAIN) {
TypeIdent (Technique<>) {
}
Values () {
MemberValue () { VertexShader =
Value () { vs_main
}
}
MemberValue () { PixelShader =
Value () { ps_main
}
}
}
}
Declaration (vs_main) {
TypeIdent (VS_OUT<>) {
}
Declaration (_in) {
TypeIdent (VS_IN<>) {
}
}
Value () {
VS_OUT _out = (VS_OUT)0;
_out.position_ = _in.position;
return out;
}
}
Declaration (ps_main) {
Attribute (earlydepthstencil) {
}
TypeIdent (float4<>) {
}
Declaration (_in) {
TypeIdent (VS_OUT<>) {
}
}
Value () {
return float4(1.0, 1.0, 1.0, 1.0);
}
}
}
#pragma once
struct Test
{
float a;
float b;
};
const Test Vals = { .a = 0.0, .b = 1.0 };
const float myConstFloat = 1.0;
[something(1.0)]
struct VS_IN
{
float3 position_ : SV_POSITION; // comment test.
}; /* comment test 2 */
[else(2.0)]
struct VS_OUT
{
float3 position_ : SV_POSITION;
};
VS_OUT vs_main(VS_IN _in)
{
VS_OUT _out = (VS_OUT)0;
_out.position_ = _in.position;
return out;
}
[earlydepthstencil]
float4 ps_main(VS_OUT _in) : COLOR0
{
return float4(1.0, 1.0, 1.0, 1.0);
}
Technique TECH_MAIN =
{
.VertexShader = vs_main,
.PixelShader = ps_main,
};
////////////////////////////////////////////////////////////////////////////////////////////////////
// generated shader for basic.esf
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
// structs
struct Test
{
float a;
float b;
};
[something(1.0)]
struct VS_IN
{
float3 position_ : SV_POSITION;
};
[else(2.0)]
struct VS_OUT
{
float3 position_ : SV_POSITION;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
// vars
const Test Vals;
const float myConstFloat = 1.0;
////////////////////////////////////////////////////////////////////////////////////////////////////
// functions
VS_OUT vs_main(VS_IN _in)
{
VS_OUT _out = (VS_OUT)0;
_out.position_ = _in.position;
return out;
}
[earlydepthstencil]
float4 ps_main(VS_OUT _in) : COLOR0
{
return float4(1.0, 1.0, 1.0, 1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment