Skip to content

Commit

Permalink
Support vertex offset mode with new D3D12_VERTEX_BUFFER_VIEW
Browse files Browse the repository at this point in the history
In vertex offset mode. we will use D3D12_VERTEX_BUFFER_VIEW to
replace SRD, the address and size fields are already in the right
place. We only need to get stride and fill the fourth DWORD. Then we
calculate offset with stride and vertex index.

For Uber fetch shader, SRD will be updated in driver.
  • Loading branch information
AMD-dwang committed Nov 27, 2023
1 parent 0b15602 commit 950c3a6
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 91 deletions.
20 changes: 11 additions & 9 deletions include/vkgcDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#define LLPC_INTERFACE_MAJOR_VERSION 70

/// LLPC minor interface version.
#define LLPC_INTERFACE_MINOR_VERSION 1
#define LLPC_INTERFACE_MINOR_VERSION 2

#ifndef LLPC_CLIENT_INTERFACE_MAJOR_VERSION
#error LLPC client version is not defined
Expand Down Expand Up @@ -80,6 +80,7 @@
// %Version History
// | %Version | Change Description |
// | -------- | ----------------------------------------------------------------------------------------------------- |
// | 70.2 | Add useSoftwareVertexBufferDescriptors to GraphicsPipelineBuildInfo |
// | 70.1 | Add cpsFlags to RayTracingPipelineBuildInfo |
// | 70.0 | Add enablePrimGeneratedQuery to PipelineOptions |
// | 69.1 | Add useBarycentric to ShaderModuleUsage |
Expand Down Expand Up @@ -1361,14 +1362,15 @@ struct GraphicsPipelineBuildInfo {
ColorTarget target[MaxColorTargets]; ///< Per-MRT color target info
} cbState; ///< Color target state

NggState nggState; ///< NGG state used for tuning and debugging
PipelineOptions options; ///< Per pipeline tuning/debugging options
bool unlinked; ///< True to build an "unlinked" half-pipeline ELF
bool dynamicVertexStride; ///< Dynamic Vertex input Stride is enabled.
bool enableUberFetchShader; ///< Use uber fetch shader
bool enableColorExportShader; ///< Explicitly build color export shader, UnlinkedStageFragment elf will
/// return extra meta data.
bool enableEarlyCompile; ///< Whether enable early compile
NggState nggState; ///< NGG state used for tuning and debugging
PipelineOptions options; ///< Per pipeline tuning/debugging options
bool unlinked; ///< True to build an "unlinked" half-pipeline ELF
bool dynamicVertexStride; ///< Dynamic Vertex input Stride is enabled.
bool enableUberFetchShader; ///< Use uber fetch shader
bool enableColorExportShader; ///< Explicitly build color export shader, UnlinkedStageFragment elf will
/// return extra meta data.
bool enableEarlyCompile; ///< Whether enable early compile
bool useSoftwareVertexBufferDescriptors; ///< Use software vertex buffer descriptors to structure SRD.
#if LLPC_CLIENT_INTERFACE_MAJOR_VERSION < 62
BinaryData shaderLibrary; ///< SPIR-V library binary data
#endif
Expand Down
3 changes: 2 additions & 1 deletion lgc/elfLinker/FetchShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ Module *FetchShader::generate() {
//
// @param [in/out] fetchFunc : The function for the fetch shader.
void FetchShader::generateFetchShaderBody(Function *fetchFunc) { // Process each vertex input.
std::unique_ptr<VertexFetch> vertexFetch(VertexFetch::create(m_lgcContext));
std::unique_ptr<VertexFetch> vertexFetch(
VertexFetch::create(m_lgcContext, m_pipelineState->getOptions().useSoftwareVertexBufferDescriptors));
auto ret = cast<ReturnInst>(fetchFunc->back().getTerminator());
BuilderImpl builder(m_pipelineState);
builder.SetInsertPoint(ret);
Expand Down
2 changes: 1 addition & 1 deletion lgc/include/lgc/patch/VertexFetch.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class VertexFetch {
virtual ~VertexFetch() {}

// Create a VertexFetch
static VertexFetch *create(LgcContext *lgcContext);
static VertexFetch *create(LgcContext *lgcContext, bool useSoftwareVertexBufferDescriptors);

// Generate code to fetch a vertex value
virtual llvm::Value *fetchVertex(llvm::Type *inputTy, const VertexInputDescription *description, unsigned location,
Expand Down
9 changes: 5 additions & 4 deletions lgc/interface/lgc/Pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,11 @@ union Options {
bool fragCoordUsesInterpLoc; // Determining fragCoord use InterpLoc
bool disableSampleMask; // Disable export of sample mask from PS
unsigned reserved20;
RayTracingIndirectMode rtIndirectMode; // Ray tracing indirect mode
bool enablePrimGeneratedQuery; // Whether to enable primitive generated counter
bool enableFragColor; // If enabled, do frag color broadcast
unsigned cpsFlags; // CPS feature flags
RayTracingIndirectMode rtIndirectMode; // Ray tracing indirect mode
bool enablePrimGeneratedQuery; // Whether to enable primitive generated counter
bool enableFragColor; // If enabled, do frag color broadcast
bool useSoftwareVertexBufferDescriptors; // Use software vertex buffer descriptors to structure SRD.
unsigned cpsFlags; // CPS feature flags
};
};
static_assert(sizeof(Options) == sizeof(Options::u32All));
Expand Down
Loading

0 comments on commit 950c3a6

Please sign in to comment.