Skip to content

Commit

Permalink
"Release 1.17 - October 4th, 2018 - Android Pie & Vulkan 1.1 Support …
Browse files Browse the repository at this point in the history
…| iOS imGUI touch & virtual keyboard | DXR Ray Tracing support | Call for contributors to change IRenderer.h"
  • Loading branch information
JenkinsConffx committed Oct 5, 2018
1 parent dff4177 commit ef6aec9
Show file tree
Hide file tree
Showing 382 changed files with 23,757 additions and 46,528 deletions.
34 changes: 17 additions & 17 deletions CommonRaytracing_3/Direct3D12Raytracing/Direct3D12Raytracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "../../Common_3/Renderer/Direct3D12/Direct3D12MemoryAllocator.h"
#include "../../Common_3/OS/Interfaces/IMemoryManager.h"

#define D3D12_GPU_VIRTUAL_ADDRESS_NULL ((D3D12_GPU_VIRTUAL_ADDRESS)0)
#define D3D12_GPU_VIRTUAL_ADDRESS_NULL ((D3D12_GPU_VIRTUAL_ADDRESS)0)
#define D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN ((D3D12_GPU_VIRTUAL_ADDRESS)-1)

typedef struct DescriptorStoreHeap
Expand Down Expand Up @@ -124,25 +124,25 @@ WRAPPED_GPU_POINTER util_create_fallback_wrapped_pointer(Raytracing* pRaytracing
/************************************************************************/
struct Raytracing
{
Renderer* pRenderer;
Renderer* pRenderer;
ID3D12DeviceRaytracingPrototype* pDxrDevice;
ID3D12RaytracingFallbackDevice* pFallbackDevice;
//DescriptorStoreHeap* pDescriptorHeap;
ID3D12RaytracingFallbackDevice* pFallbackDevice;
//DescriptorStoreHeap* pDescriptorHeap;
uint64_t mDescriptorsAllocated;
};

struct RaytracingShader
{
ID3DBlob* pShaderBlob;
LPCWSTR pName;
ID3DBlob* pShaderBlob;
LPCWSTR pName;
};

struct AccelerationStructure
{
Buffer* pBuffer;
D3D12_RAYTRACING_GEOMETRY_DESC* pGeometryDescs;
Buffer* pInstanceDescBuffer;
WRAPPED_GPU_POINTER mFallbackPointer;
Buffer* pBuffer;
D3D12_RAYTRACING_GEOMETRY_DESC* pGeometryDescs;
Buffer* pInstanceDescBuffer;
WRAPPED_GPU_POINTER mFallbackPointer;
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE mType;
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS mFlags;
uint32_t mDescCount;
Expand All @@ -152,17 +152,17 @@ struct RaytracingPipeline
{
union
{
ID3D12StateObjectPrototype* pDxrPipeline;
ID3D12StateObjectPrototype* pDxrPipeline;
ID3D12RaytracingFallbackStateObject* pFallbackPipeline;
};
};

struct RaytracingShaderTable
{
RaytracingPipeline* pPipeline;
Buffer* pBuffer;
D3D12_GPU_DESCRIPTOR_HANDLE mViewGpuDescriptorHandle[DESCRIPTOR_UPDATE_FREQ_COUNT];
D3D12_GPU_DESCRIPTOR_HANDLE mSamplerGpuDescriptorHandle[DESCRIPTOR_UPDATE_FREQ_COUNT];
RaytracingPipeline* pPipeline;
Buffer* pBuffer;
D3D12_GPU_DESCRIPTOR_HANDLE mViewGpuDescriptorHandle[DESCRIPTOR_UPDATE_FREQ_COUNT];
D3D12_GPU_DESCRIPTOR_HANDLE mSamplerGpuDescriptorHandle[DESCRIPTOR_UPDATE_FREQ_COUNT];
uint32_t mViewDescriptorCount[DESCRIPTOR_UPDATE_FREQ_COUNT];
uint32_t mSamplerDescriptorCount[DESCRIPTOR_UPDATE_FREQ_COUNT];
uint64_t mMaxEntrySize;
Expand Down Expand Up @@ -236,7 +236,7 @@ void addAccelerationStructure(Raytracing* pRaytracing, const AccelerationStructu
pOut->Triangles.IndexCount = (UINT)pGeom->pIndexBuffer->mDesc.mSize /
(pGeom->pIndexBuffer->mDesc.mIndexType == INDEX_TYPE_UINT16 ? sizeof(uint16_t) : sizeof(uint32_t));
pOut->Triangles.IndexFormat = pGeom->pIndexBuffer->mDxIndexFormat;
; }
; }

pOut->Triangles.VertexBuffer.StartAddress = pGeom->pVertexBuffer->mDxGpuAddress;
pOut->Triangles.VertexBuffer.StrideInBytes = (UINT)pGeom->pVertexBuffer->mDesc.mVertexStride;
Expand Down Expand Up @@ -428,7 +428,7 @@ void addRaytracingRootSignature(Raytracing* pRaytracing, const ShaderResource* p
pRootSignature->mDescriptorCount = resourceCount;
// Raytracing is executed in compute path
pRootSignature->mPipelineType = PIPELINE_TYPE_COMPUTE;

if (resourceCount)
pRootSignature->pDescriptors = (DescriptorInfo*)conf_calloc(pRootSignature->mDescriptorCount, sizeof(*pRootSignature->pDescriptors));

Expand Down
76 changes: 38 additions & 38 deletions CommonRaytracing_3/Interfaces/IRaytracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static inline ENUM_TYPE operator&=(ENUM_TYPE& a, ENUM_TYPE b) \
#if defined(VULKAN)
#define ApiExport //extern "C"
#else
#define ApiExport
#define ApiExport
#endif

typedef struct Renderer Renderer;
Expand Down Expand Up @@ -91,81 +91,81 @@ MAKE_ENUM_FLAG(unsigned, AccelerationStructureInstanceFlags)
typedef struct AccelerationStructureInstanceDesc
{
/// Bottom Level Acceleration structure to instance (Instancing Geometry stored in this acceleration structure)
AccelerationStructure* pAccelerationStructure;
AccelerationStructure* pAccelerationStructure;
/// Row major affine transform for transforming the vertices in the geometry stored in pAccelerationStructure
float mTransform[12];
float mTransform[12];
/// User defined instanced ID which can be queried in the shader
unsigned mInstanceID;
unsigned mInstanceMask;
unsigned mInstanceContributionToHitGroupIndex;
AccelerationStructureInstanceFlags mFlags;
AccelerationStructureInstanceFlags mFlags;
} AccelerationStructureInstanceDesc;

typedef struct AccelerationStructureGeometryDesc
{
AccelerationStructureGeometryType mType;
AccelerationStructureGeometryFlags mFlags;
Buffer* pVertexBuffer;
Buffer* pIndexBuffer;
AccelerationStructureGeometryType mType;
AccelerationStructureGeometryFlags mFlags;
Buffer* pVertexBuffer;
Buffer* pIndexBuffer;
} AccelerationStructureGeometryDesc;
/************************************************************************/
// #mType - Either Top or Bottom Level
// Bottom Level Structures define the geometry data such as vertex buffers, index buffers
// Top Level Structures define the instance data for the geometry such as instance matrix, instance ID, ...
// Bottom Level Structures define the geometry data such as vertex buffers, index buffers
// Top Level Structures define the instance data for the geometry such as instance matrix, instance ID, ...
// #mDescCount - Number of geometries or instances in this structure
/************************************************************************/
typedef struct AccelerationStructureDesc
{
AccelerationStructureType mType;
AccelerationStructureBuildFlags mFlags;
AccelerationStructureType mType;
AccelerationStructureBuildFlags mFlags;
/// Number of geometries / instances in thie acceleration structure
unsigned mDescCount;
union
{
/// Array of instances in the top level acceleration structure
AccelerationStructureInstanceDesc* pInstanceDescs;
AccelerationStructureInstanceDesc* pInstanceDescs;
/// Array of geometries in the bottom level acceleration structure
AccelerationStructureGeometryDesc* pGeometryDescs;
AccelerationStructureGeometryDesc* pGeometryDescs;
};
} AccelerationStructureDesc;
/************************************************************************/
// Defines which shaders will be used by this hit group
// #pIntersectionShaderName - Name of shader used to test intersection with ray
// This will be NULL as long as user does not specify ACCELERATION_STRUCTURE_GEOMETRY_TYPE_PROCEDURAL_PRIMITIVE_AABBS
// This will be NULL as long as user does not specify ACCELERATION_STRUCTURE_GEOMETRY_TYPE_PROCEDURAL_PRIMITIVE_AABBS
// #pAnyHitShaderName - Name of shader executed when a ray hits
// This will be NULL if user specifies ACCELERATION_STRUCTURE_GEOMETRY_FLAG_OPAQUE in geometry creation
// This shader is usually used for work like alpha testing geometry to see if an intersection is valid
// This will be NULL if user specifies ACCELERATION_STRUCTURE_GEOMETRY_FLAG_OPAQUE in geometry creation
// This shader is usually used for work like alpha testing geometry to see if an intersection is valid
// #pClosestHitShaderName - Name of shader executed for the intersection closest to the ray
// This shader will do most of the work like shading
// This shader will do most of the work like shading
// #pHitGroupName - User defined name of the hit group. Use the same name when creating the shader table
/************************************************************************/
typedef struct RaytracingHitGroup
{
RootSignature* pRootSignature;
RaytracingShader* pIntersectionShader;
RaytracingShader* pAnyHitShader;
RaytracingShader* pClosestHitShader;
const char* pHitGroupName;
RootSignature* pRootSignature;
RaytracingShader* pIntersectionShader;
RaytracingShader* pAnyHitShader;
RaytracingShader* pClosestHitShader;
const char* pHitGroupName;
} RaytracingHitGroup;
/************************************************************************/
// #pGlobalRootSignature - Root Signature used by all shaders in the ppShaders array
// #ppShaders - Array of all shaders which can be called during the raytracing operation
// This includes the ray generation shader, all miss, any hit, closest hit shaders
// This includes the ray generation shader, all miss, any hit, closest hit shaders
// #pHitGroups - Name of the hit groups which will tell the pipeline about which combination of hit shaders to use
// #mPayloadSize - Size of the payload struct for passing data to and from the shaders.
// Example - float4 payload sent by raygen shader which will be filled by miss shader as a skybox color
// or by hit shader as shaded color
// Example - float4 payload sent by raygen shader which will be filled by miss shader as a skybox color
// or by hit shader as shaded color
// #mAttributeSize - Size of the intersection attribute. As long as user uses the default intersection shader
// this size is sizeof(float2) which represents the ZW of the barycentric co-ordinates of the intersection
// this size is sizeof(float2) which represents the ZW of the barycentric co-ordinates of the intersection
/************************************************************************/
typedef struct RaytracingPipelineDesc
{
RootSignature* pGlobalRootSignature;
RaytracingShader* pRayGenShader;
RootSignature* pRayGenRootSignature;
RaytracingShader** ppMissShaders;
RootSignature** ppMissRootSignatures;
RaytracingHitGroup* pHitGroups;
RootSignature* pGlobalRootSignature;
RaytracingShader* pRayGenShader;
RootSignature* pRayGenRootSignature;
RaytracingShader** ppMissShaders;
RootSignature** ppMissRootSignatures;
RaytracingHitGroup* pHitGroups;
unsigned mMissShaderCount;
unsigned mHitGroupCount;
// #TODO : Remove this after adding shader reflection for raytracing shaders
Expand All @@ -177,15 +177,15 @@ typedef struct RaytracingPipelineDesc

typedef struct RaytracingShaderTableRecordDesc
{
const char* pName;
RootSignature* pRootSignature;
const char* pName;
RootSignature* pRootSignature;
DescriptorData* pRootData;
unsigned mRootDataCount;
} RaytracingShaderTableRecordDesc;

typedef struct RaytracingShaderTableDesc
{
RaytracingPipeline* pPipeline;
RaytracingPipeline* pPipeline;
RaytracingShaderTableRecordDesc* pRayGenShader;
RaytracingShaderTableRecordDesc* pMissShaders;
RaytracingShaderTableRecordDesc* pHitGroups;
Expand All @@ -197,9 +197,9 @@ typedef struct RaytracingDispatchDesc
{
uint32_t mWidth;
uint32_t mHeight;
AccelerationStructure* pTopLevelAccelerationStructure;
AccelerationStructure* pTopLevelAccelerationStructure;
// #TODO: Provide a way to provide offsets into the shader table
RaytracingShaderTable* pShaderTable;
RaytracingShaderTable* pShaderTable;
} RaytracingDispatchDesc;

ApiExport void initRaytracing(Renderer* pRenderer, Raytracing** ppRaytracing);
Expand Down
Loading

0 comments on commit ef6aec9

Please sign in to comment.