Files
UnrealEngineUWP/Engine/Source/Developer/ShaderCompilerCommon/Public/HlslccHeaderWriter.h
Ryan Vance 96bac36aa9 VKRT:
Add ray tracing shader types
Add initial ray tracing pipeline creation
Add acceleration structure descriptor type
Add basic ray tracing pipeline, occlusion support initially
Strip reflection from ray tracing shader spirv to deal with validation warnings
Don't use an array of vk descriptor types directly, this breaks with non-contiguous enum values which are common in extensions. Using a TMap from descriptor type to values instead.
Don't store vk types in the serialized shader header, translate to and from our own internal enum types to avoid similar non-contiguous value issues.
Re-enabled ray tracing compilation on windows desktop, explicitly disable runtime support using GRHISupportsRayTracing

Todo:
We need to deal with the lack of a 1:1 mapping between shader stages and frequencies for ray tracing hit groups. This is a one to many mapping which doesn't work with how most of the Vulkan RHI is authored. For now I'm assuming a hitgroup maps to a CHS.
Ray tracing shader descriptor allocation and pending state support. While we are serializing the descriptors for ray tracing shaders, we're not allocating or updating them yet which is the last large chunk needed to trace rays.
Fix spirv binary version mismatch validation error. This basically needs a local dxc modification which explicitly sets the spirv binary version to work around incorrect assuptions in dxc which is causing validation failures.
Add another local dxc modification to allow for arbirary struct size support using VK_EXT_scalar_block_layout for ray tracing shaders.

#rb jeannoe.morissette, lukas.hermanns

[CL 16711940 by Ryan Vance in ue5-main branch]
2021-06-17 17:15:16 -04:00

77 lines
3.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "CrossCompilerCommon.h"
// Forward declaration from <spirv_reflect.h>
struct SpvReflectInterfaceVariable;
struct SpvReflectBlockVariable;
// Cross compiler support/common functionality
namespace CrossCompiler
{
class SHADERCOMPILERCOMMON_API FHlslccHeaderWriter
{
public:
void WriteSourceInfo(const TCHAR* SourceName, const TCHAR* EntryPointName, const TCHAR* DebugGroupName = nullptr);
void WriteCompilerInfo(const TCHAR* CompilerName = TEXT("ShaderConductor"));
void WriteInputAttribute(const SpvReflectInterfaceVariable& Attribute);
void WriteInputAttribute(const TCHAR* AttributeName, const TCHAR* TypeSpecifier, int32 Location, bool bLocationPrefix, bool bLocationSuffix);
void WriteOutputAttribute(const SpvReflectInterfaceVariable& Attribute);
void WriteOutputAttribute(const TCHAR* AttributeName, const TCHAR* TypeSpecifier, int32 Location, bool bLocationPrefix, bool bLocationSuffix);
void WriteUniformBlock(const TCHAR* ResourceName, uint32 BindingIndex);
void WritePackedGlobal(const TCHAR* ResourceName, EPackedTypeName PackedType, uint32 ByteOffset, uint32 ByteSize);
void WritePackedGlobal(const SpvReflectBlockVariable& Variable);
void WritePackedUB(uint32 BindingIndex);
void WritePackedUBField(const TCHAR* ResourceName, uint32 ByteOffset, uint32 ByteSize);
void WritePackedUBGlobalCopy(uint32 SourceCB, uint32 SourceOffset, uint32 DestCBIndex, uint32 DestCBPrecision, uint32 DestOffset, uint32 Size, bool bGroupFlattenedUBs = false);
void WriteSRV(const TCHAR* ResourceName, uint32 BindingIndex, uint32 Count = 1);
void WriteSRV(const TCHAR* ResourceName, uint32 BindingIndex, uint32 Count, const TArray<FString>& AssociatedResourceNames);
void WriteUAV(const TCHAR* ResourceName, uint32 BindingIndex, uint32 Count = 1);
void WriteSamplerState(const TCHAR* ResourceName, uint32 BindingIndex);
void WriteNumThreads(uint32 NumThreadsX, uint32 NumThreadsY, uint32 NumThreadsZ);
void WriteAccelerationStructures(const TCHAR* ResourceName, uint32 BindingIndex);
void WriteSideTable(const TCHAR* ResourceName, uint32 SideTableIndex);
void WriteArgumentBuffers(uint32 BindingIndex, const TArray<uint32>& ResourceIndices);
/** Returns the finalized meta data. */
FString ToString() const;
private:
void WriteIOAttribute(FString& OutMetaData, const TCHAR* AttributeName, const TCHAR* TypeSpecifier, int32 Location, bool bLocationPrefix, bool bLocationSuffix);
void WriteIOAttribute(FString& OutMetaData, const SpvReflectInterfaceVariable& Attribute, bool bIsInput);
private:
struct FMetaDataStrings
{
FString SourceInfo;
FString CompilerInfo;
FString InputAttributes;
FString OutputAttributes;
FString UniformBlocks;
FString PackedGlobals;
FString PackedUB;
FString PackedUBFields;
FString PackedUBGlobalCopies;
FString SRVs; // Shader resource views (SRV) and samplers
FString UAVs; // Unordered access views (UAV)
FString SamplerStates;
FString NumThreads;
FString ExternalTextures; // External texture resources (Vulkan ES3.1 profile only)
FString SideTable; // Side table for additional indices, e.,g. "spvBufferSizeConstants(31)" (Metal only)
FString ArgumentBuffers; // Indirect argument buffers (Metal only)
FString AccelerationStructures;
};
private:
FMetaDataStrings Strings;
};
}