Skip to content

Commit

Permalink
Supported shader barycentric coords on OpenGL, Vulkan and Metal
Browse files Browse the repository at this point in the history
  • Loading branch information
jay3d committed May 3, 2024
1 parent 57d8a08 commit ba661ef
Show file tree
Hide file tree
Showing 22 changed files with 545 additions and 158 deletions.
2 changes: 2 additions & 0 deletions 3rdparty/glslang/glslang/HLSL/hlslParseHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9527,6 +9527,8 @@ bool HlslParseContext::isInputBuiltIn(const TQualifier& qualifier) const
case EbvSampleMask:
case EbvSamplePosition:
case EbvViewportIndex:
case EbvBaryCoordEXT:
case EbvBaryCoordNoPerspEXT:
return language == EShLangFragment;
case EbvGlobalInvocationId:
case EbvLocalInvocationIndex:
Expand Down
2 changes: 2 additions & 0 deletions 3rdparty/glslang/glslang/HLSL/hlslScanContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,8 @@ void HlslScanContext::fillInKeywordMap()
(*SemanticMap)["SV_DEPTHGREATEREQUAL"] = EbvFragDepthGreater;
(*SemanticMap)["SV_DEPTHLESSEQUAL"] = EbvFragDepthLesser;
(*SemanticMap)["SV_STENCILREF"] = EbvFragStencilRef;
(*SemanticMap)["SV_BARYCENTRICS"] = EbvBaryCoordEXT;
(*SemanticMap)["SV_BARYCENTRICS1"] = EbvBaryCoordNoPerspEXT;
}

void HlslScanContext::deleteKeywordMap()
Expand Down
61 changes: 32 additions & 29 deletions 3rdparty/spirv-cross/spirv_msl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12576,7 +12576,7 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in
else
quals = member_location_attribute_qualifier(type, index);

if (builtin == BuiltInBaryCoordKHR || builtin == BuiltInBaryCoordNoPerspKHR)
if (builtin == BuiltInBaryCoordKHR)
{
if (has_member_decoration(type.self, index, DecorationFlat) ||
has_member_decoration(type.self, index, DecorationCentroid) ||
Expand All @@ -12594,35 +12594,38 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in
// FragCoord builtin; it's always noperspective on Metal.
if (!type_is_integral(mbr_type) && (!is_builtin || builtin != BuiltInFragCoord))
{
if (has_member_decoration(type.self, index, DecorationFlat))
if (builtin != BuiltInBaryCoordKHR && builtin != BuiltInBaryCoordNoPerspKHR)
{
if (!quals.empty())
quals += ", ";
quals += "flat";
}
else if (has_member_decoration(type.self, index, DecorationCentroid))
{
if (!quals.empty())
quals += ", ";
if (has_member_decoration(type.self, index, DecorationNoPerspective))
quals += "centroid_no_perspective";
else
quals += "centroid_perspective";
}
else if (has_member_decoration(type.self, index, DecorationSample))
{
if (!quals.empty())
quals += ", ";
if (has_member_decoration(type.self, index, DecorationNoPerspective))
quals += "sample_no_perspective";
else
quals += "sample_perspective";
}
else if (has_member_decoration(type.self, index, DecorationNoPerspective))
{
if (!quals.empty())
quals += ", ";
quals += "center_no_perspective";
if (has_member_decoration(type.self, index, DecorationFlat))
{
if (!quals.empty())
quals += ", ";
quals += "flat";
}
else if (has_member_decoration(type.self, index, DecorationCentroid))
{
if (!quals.empty())
quals += ", ";
if (has_member_decoration(type.self, index, DecorationNoPerspective))
quals += "centroid_no_perspective";
else
quals += "centroid_perspective";
}
else if (has_member_decoration(type.self, index, DecorationSample))
{
if (!quals.empty())
quals += ", ";
if (has_member_decoration(type.self, index, DecorationNoPerspective))
quals += "sample_no_perspective";
else
quals += "sample_perspective";
}
else if (has_member_decoration(type.self, index, DecorationNoPerspective))
{
if (!quals.empty())
quals += ", ";
quals += "center_no_perspective";
}
}
}

Expand Down
55 changes: 30 additions & 25 deletions bindings/bf/bgfx.bf
Original file line number Diff line number Diff line change
Expand Up @@ -1046,126 +1046,131 @@ public static class bgfx
/// </summary>
FragmentOrdering = 0x0000000000000040,

/// <summary>
/// Fragment barycentric coordinates are available in fragment shader.
/// </summary>
FragmentBarycentric = 0x0000000000000080,

/// <summary>
/// Graphics debugger is present.
/// </summary>
GraphicsDebugger = 0x0000000000000080,
GraphicsDebugger = 0x0000000000000100,

/// <summary>
/// HDR10 rendering is supported.
/// </summary>
Hdr10 = 0x0000000000000100,
Hdr10 = 0x0000000000000200,

/// <summary>
/// HiDPI rendering is supported.
/// </summary>
Hidpi = 0x0000000000000200,
Hidpi = 0x0000000000000400,

/// <summary>
/// Image Read/Write is supported.
/// </summary>
ImageRw = 0x0000000000000400,
ImageRw = 0x0000000000000800,

/// <summary>
/// 32-bit indices are supported.
/// </summary>
Index32 = 0x0000000000000800,
Index32 = 0x0000000000001000,

/// <summary>
/// Instancing is supported.
/// </summary>
Instancing = 0x0000000000001000,
Instancing = 0x0000000000002000,

/// <summary>
/// Occlusion query is supported.
/// </summary>
OcclusionQuery = 0x0000000000002000,
OcclusionQuery = 0x0000000000004000,

/// <summary>
/// Renderer is on separate thread.
/// </summary>
RendererMultithreaded = 0x0000000000004000,
RendererMultithreaded = 0x0000000000008000,

/// <summary>
/// Multiple windows are supported.
/// </summary>
SwapChain = 0x0000000000008000,
SwapChain = 0x0000000000010000,

/// <summary>
/// 2D texture array is supported.
/// </summary>
Texture2dArray = 0x0000000000010000,
Texture2dArray = 0x0000000000020000,

/// <summary>
/// 3D textures are supported.
/// </summary>
Texture3d = 0x0000000000020000,
Texture3d = 0x0000000000040000,

/// <summary>
/// Texture blit is supported.
/// </summary>
TextureBlit = 0x0000000000040000,
TextureBlit = 0x0000000000080000,

/// <summary>
/// Transparent back buffer supported.
/// </summary>
TransparentBackbuffer = 0x0000000000080000,
TextureCompareReserved = 0x0000000000100000,
TransparentBackbuffer = 0x0000000000100000,
TextureCompareReserved = 0x0000000000200000,

/// <summary>
/// Texture compare less equal mode is supported.
/// </summary>
TextureCompareLequal = 0x0000000000200000,
TextureCompareLequal = 0x0000000000400000,

/// <summary>
/// Cubemap texture array is supported.
/// </summary>
TextureCubeArray = 0x0000000000400000,
TextureCubeArray = 0x0000000000800000,

/// <summary>
/// CPU direct access to GPU texture memory.
/// </summary>
TextureDirectAccess = 0x0000000000800000,
TextureDirectAccess = 0x0000000001000000,

/// <summary>
/// Read-back texture is supported.
/// </summary>
TextureReadBack = 0x0000000001000000,
TextureReadBack = 0x0000000002000000,

/// <summary>
/// Vertex attribute half-float is supported.
/// </summary>
VertexAttribHalf = 0x0000000002000000,
VertexAttribHalf = 0x0000000004000000,

/// <summary>
/// Vertex attribute 10_10_10_2 is supported.
/// </summary>
VertexAttribUint10 = 0x0000000004000000,
VertexAttribUint10 = 0x0000000008000000,

/// <summary>
/// Rendering with VertexID only is supported.
/// </summary>
VertexId = 0x0000000008000000,
VertexId = 0x0000000010000000,

/// <summary>
/// PrimitiveID is available in fragment shader.
/// </summary>
PrimitiveId = 0x0000000010000000,
PrimitiveId = 0x0000000020000000,

/// <summary>
/// Viewport layer is available in vertex shader.
/// </summary>
ViewportLayerArray = 0x0000000020000000,
ViewportLayerArray = 0x0000000040000000,

/// <summary>
/// Draw indirect with indirect count is supported.
/// </summary>
DrawIndirectCount = 0x0000000040000000,
DrawIndirectCount = 0x0000000080000000,

/// <summary>
/// All texture compare modes are supported.
/// </summary>
TextureCompareAll = 0x0000000000300000,
TextureCompareAll = 0x0000000000600000,
}

[AllowDuplicates]
Expand Down
Loading

0 comments on commit ba661ef

Please sign in to comment.