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 authored and Jamil Halabi committed Oct 8, 2024
1 parent fdb09ca commit 7712a5d
Show file tree
Hide file tree
Showing 22 changed files with 512 additions and 125 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 @@ -9522,6 +9522,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
5 changes: 4 additions & 1 deletion 3rdparty/spirv-cross/spirv_msl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12758,7 +12758,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 @@ -12776,6 +12776,8 @@ 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 (builtin != BuiltInBaryCoordKHR && builtin != BuiltInBaryCoordNoPerspKHR)
{
if (has_member_decoration(type.self, index, DecorationFlat))
{
if (!quals.empty())
Expand Down Expand Up @@ -12807,6 +12809,7 @@ string CompilerMSL::member_attribute_qualifier(const SPIRType &type, uint32_t in
quals += "center_no_perspective";
}
}
}

if (!quals.empty())
return " [[" + quals + "]]";
Expand Down
53 changes: 29 additions & 24 deletions bindings/bf/bgfx.bf
Original file line number Diff line number Diff line change
Expand Up @@ -1051,121 +1051,126 @@ public static class bgfx
/// </summary>
FragmentOrdering = 0x0000000000000080,

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

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

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

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

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

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

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

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

/// <summary>
/// PrimitiveID is available in fragment shader.
/// </summary>
PrimitiveId = 0x0000000000008000,
PrimitiveId = 0x0000000000010000,

/// <summary>
/// Renderer is on separate thread.
/// </summary>
RendererMultithreaded = 0x0000000000010000,
RendererMultithreaded = 0x0000000000020000,

/// <summary>
/// Multiple windows are supported.
/// </summary>
SwapChain = 0x0000000000020000,
SwapChain = 0x0000000000040000,

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

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

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

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

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

/// <summary>
/// 2D texture array is supported.
/// </summary>
Texture2dArray = 0x0000000001000000,
Texture2dArray = 0x0000000002000000,

/// <summary>
/// 3D textures are supported.
/// </summary>
Texture3d = 0x0000000002000000,
Texture3d = 0x0000000004000000,

/// <summary>
/// Transparent back buffer supported.
/// </summary>
TransparentBackbuffer = 0x0000000004000000,
TransparentBackbuffer = 0x0000000008000000,

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

/// <summary>
/// Vertex attribute 10_10_10_2 is supported.
/// </summary>
VertexAttribUint10 = 0x0000000010000000,
VertexAttribUint10 = 0x0000000020000000,

/// <summary>
/// Rendering with VertexID only is supported.
/// </summary>
VertexId = 0x0000000020000000,
VertexId = 0x0000000040000000,

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

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

[AllowDuplicates]
Expand Down
53 changes: 29 additions & 24 deletions bindings/cs/bgfx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,121 +1050,126 @@ public enum CapsFlags : ulong
/// </summary>
FragmentOrdering = 0x0000000000000080,

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

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

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

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

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

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

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

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

/// <summary>
/// PrimitiveID is available in fragment shader.
/// </summary>
PrimitiveId = 0x0000000000008000,
PrimitiveId = 0x0000000000010000,

/// <summary>
/// Renderer is on separate thread.
/// </summary>
RendererMultithreaded = 0x0000000000010000,
RendererMultithreaded = 0x0000000000020000,

/// <summary>
/// Multiple windows are supported.
/// </summary>
SwapChain = 0x0000000000020000,
SwapChain = 0x0000000000040000,

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

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

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

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

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

/// <summary>
/// 2D texture array is supported.
/// </summary>
Texture2dArray = 0x0000000001000000,
Texture2dArray = 0x0000000002000000,

/// <summary>
/// 3D textures are supported.
/// </summary>
Texture3d = 0x0000000002000000,
Texture3d = 0x0000000004000000,

/// <summary>
/// Transparent back buffer supported.
/// </summary>
TransparentBackbuffer = 0x0000000004000000,
TransparentBackbuffer = 0x0000000008000000,

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

/// <summary>
/// Vertex attribute 10_10_10_2 is supported.
/// </summary>
VertexAttribUint10 = 0x0000000010000000,
VertexAttribUint10 = 0x0000000020000000,

/// <summary>
/// Rendering with VertexID only is supported.
/// </summary>
VertexId = 0x0000000020000000,
VertexId = 0x0000000040000000,

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

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

[Flags]
Expand Down
Loading

0 comments on commit 7712a5d

Please sign in to comment.