public HitProgram(string ahsExport, string chsExport, string name) { HitGroupDescription desc = new HitGroupDescription(); desc.AnyHitShaderImport = ahsExport; desc.ClosestHitShaderImport = chsExport; desc.HitGroupExport = name; subObject = new StateSubObject(desc); }
public HitProgram(string ahsExport, string chsExport, string name) { ExportName = name; Desc = new HitGroupDescription(); Desc.IntersectionShaderImport = null; Desc.Type = HitGroupType.Triangles; Desc.HitGroupExport = name; Desc.AnyHitShaderImport = ahsExport; Desc.ClosestHitShaderImport = chsExport; subObject = new StateSubObject(Desc); }
internal DxilLibrary(IDxcBlob blob, string[] entryPoints) { var shaderBytes = Dxc.GetBytesFromBlob(blob); ExportDescription[] exportDesc = new ExportDescription[entryPoints.Length]; for (int i = 0; i < exportDesc.Length; i++) { exportDesc[i] = new ExportDescription(); exportDesc[i].Name = entryPoints[i]; exportDesc[i].Flags = ExportFlags.None; exportDesc[i].ExportToRename = null; } libraryDesc = new DxilLibraryDescription(new ShaderBytecode(shaderBytes), exportDesc); stateSubObject = new StateSubObject(libraryDesc); }
public DxilLibrary(IDxcBlob pBlob, string[] entryPoint) { var pShaderBytecode = Dxc.GetBytesFromBlob(pBlob); ExportDescription[] exportDesc = new ExportDescription[entryPoint.Length]; for (int i = 0; i < exportDesc.Length; i++) { exportDesc[i] = new ExportDescription(); exportDesc[i].Name = entryPoint[i]; exportDesc[i].Flags = ExportFlags.None; exportDesc[i].ExportToRename = null; } DxilLibraryDescription dxilLibDesc = new DxilLibraryDescription(new ShaderBytecode(pShaderBytecode), exportDesc); this.stateSubObject = new StateSubObject(dxilLibDesc); }
public GlobalRootSignature(ID3D12Device5 pDevice, RootSignatureDescription desc) { pRootSig = new Vortice.Direct3D12.GlobalRootSignature(); pRootSig.RootSignature = pDevice.CreateRootSignature(desc, RootSignatureVersion.Version1); suboject = new StateSubObject(pRootSig); }
public ExportAssociation(string[] exportNames, StateSubObject pSubobjectToAssociate) { this.association = new SubObjectToExportsAssociation(pSubobjectToAssociate, exportNames); this.subobject = new StateSubObject(this.association); }
public ShaderConfig(int maxAttributeSizeInBytes, int maxPayloadSizeInBytes) { this.shaderConfig = new RaytracingShaderConfig(maxPayloadSizeInBytes, maxAttributeSizeInBytes); this.subObject = new StateSubObject(this.shaderConfig); }
public PipelineConfig(int maxTraceRecursionDepth) { config = new RaytracingPipelineConfig(maxTraceRecursionDepth); suboject = new StateSubObject(config); }
public void CreateRtPipelineState() { var rtpipeline = new RTPipeline(); // Need 10 subobjects: // 1 for the DXIL library // 1 for hit-group // 2 for RayGen root-signature (root-signature and the subobject association) // 2 for hit-program root-signature (root-signature and the subobject association) // 2 for miss-shader root-signature (signature and association) // 2 for shader config (shared between all programs. 1 for the config, 1 for association) // 1 for pipeline config // 1 for the global root signature StateSubObject[] subobjects = new StateSubObject[12]; int index = 0; // Create the DXIL library DxilLibrary dxilLib = rtpipeline.CreateDxilLibrary(); subobjects[index++] = dxilLib.stateSubObject; // 0 Library HitProgram hitProgram = new HitProgram(null, RTPipeline.kClosestHitShader, RTPipeline.kHitGroup); subobjects[index++] = hitProgram.subObject; // 1 Hit Group // Create the ray-gen root-signature and association Structs.LocalRootSignature rgsRootSignature = new Structs.LocalRootSignature(mpDevice, rtpipeline.CreateRayGenRootDesc()); subobjects[index] = rgsRootSignature.subobject; // 2 RayGen Root Sig int rgsRootIndex = index++; // 2 ExportAssociation rgsRootAssociation = new ExportAssociation(new string[] { RTPipeline.kRayGenShader }, subobjects[rgsRootIndex]); subobjects[index++] = rgsRootAssociation.subobject; // 3 Associate Root Sig to RGS // Create the hit root-signature and association Structs.LocalRootSignature hitRootSignature = new Structs.LocalRootSignature(mpDevice, rtpipeline.CreateHitRootDesc()); subobjects[index] = hitRootSignature.subobject; // 4 Hit Root Sig int hitRootIndex = index++; // 4 ExportAssociation hitRootAssociation = new ExportAssociation(new string[] { RTPipeline.kClosestHitShader }, subobjects[hitRootIndex]); // 5 Associate Hit Root Sig to Hit Group subobjects[index++] = hitRootAssociation.subobject; // 6 Associate Hit Root Sig to Hit Group // Create the miss root-signature and association RootSignatureDescription emptyDesc = new RootSignatureDescription(RootSignatureFlags.LocalRootSignature); Structs.LocalRootSignature missRootSignature = new Structs.LocalRootSignature(mpDevice, emptyDesc); subobjects[index] = missRootSignature.subobject; // 6 Miss Root Sig int missRootIndex = index++; // 6 ExportAssociation missRootAssociation = new ExportAssociation(new string[] { RTPipeline.kMissShader }, subobjects[missRootIndex]); subobjects[index++] = missRootAssociation.subobject; // 7 Associate Miss Root Sig to Miss Shader // Bind the payload size to the programs ShaderConfig shaderConfig = new ShaderConfig(sizeof(float) * 2, sizeof(float) * 4); subobjects[index] = shaderConfig.subObject; // 8 Shader Config; int shaderConfigIndex = index++; // 8 string[] shaderExports = new string[] { RTPipeline.kMissShader, RTPipeline.kClosestHitShader, RTPipeline.kRayGenShader }; ExportAssociation configAssociation = new ExportAssociation(shaderExports, subobjects[shaderConfigIndex]); subobjects[index++] = configAssociation.subobject; // 9 Associate Shader Config to Miss, CHS, RGS // Create the pipeline config PipelineConfig config = new PipelineConfig(1); subobjects[index++] = config.suboject; // 10 // Create the global root signature and store the empty signature Structs.GlobalRootSignature root = new Structs.GlobalRootSignature(mpDevice, new RootSignatureDescription()); mpEmptyRootSig = root.pRootSig.RootSignature; subobjects[index++] = root.suboject; // 11 // Create the state StateObjectDescription desc = new StateObjectDescription(StateObjectType.RaytracingPipeline, subobjects); mpPipelineState = mpDevice.CreateStateObject(desc); }
public void CreateRtPipelineState() { var rtpipeline = new RTPipeline(); // Need 10 subobjects: // 1 for the DXIL library // 1 for hit-group // 2 for the hit-groups (triangle hit group, plane hit-group) // 2 for RayGen root-signature (root-signature and the subobject association) // 2 for triangle hit-program root-signature (root-signature and the subobject association) // 2 for plane hit-program and miss-shader root-signature (signature and association) // 2 for shader config (shared between all programs. 1 for the config, 1 for association) // 1 for pipeline config // 1 for the global root signature StateSubObject[] subobjects = new StateSubObject[13]; int index = 0; // Create the DXIL library DxilLibrary dxilLib = rtpipeline.CreateDxilLibrary(); subobjects[index++] = dxilLib.stateSubObject; // 0 Library // Create the triangle HitProgram HitProgram triHitProgram = new HitProgram(null, RTPipeline.kTriangleChs, RTPipeline.kTriHitGroup); subobjects[index++] = triHitProgram.subObject; // 1 Triangle Hit Group // Create the plane HitProgram HitProgram planeHitProgram = new HitProgram(null, RTPipeline.kPlaneChs, RTPipeline.kPlaneHitGroup); subobjects[index++] = planeHitProgram.subObject; // 2 Plane Hit Group // Create the ray-gen root-signature and association Structs.LocalRootSignature rgsRootSignature = new Structs.LocalRootSignature(mpDevice, rtpipeline.CreateRayGenRootDesc()); subobjects[index] = rgsRootSignature.subobject; // 3 RayGen Root Sig int rgsRootIndex = index++; // 3 ExportAssociation rgsRootAssociation = new ExportAssociation(new string[] { RTPipeline.kRayGenShader }, subobjects[rgsRootIndex]); subobjects[index++] = rgsRootAssociation.subobject; // 4 Associate Root Sig to RGS // Create the tri hit root-signature and association Structs.LocalRootSignature triHitRootSignature = new Structs.LocalRootSignature(mpDevice, rtpipeline.CreateTriangleHitRootDesc()); subobjects[index] = triHitRootSignature.subobject; // 5 Triangle Hit Root Sig int triHitRootIndex = index++; // 5 ExportAssociation triHitRootAssociation = new ExportAssociation(new string[] { RTPipeline.kTriangleChs }, subobjects[triHitRootIndex]); // 5 Associate Hit Root Sig to Hit Group subobjects[index++] = triHitRootAssociation.subobject; // 6 Associate Hit Root Sig to Hit Group // Create the empty root-signature and association it with the plane hit-program and miss-shader RootSignatureDescription emptyDesc = new RootSignatureDescription(RootSignatureFlags.LocalRootSignature); Structs.LocalRootSignature emptyRootSignature = new Structs.LocalRootSignature(mpDevice, emptyDesc); subobjects[index] = emptyRootSignature.subobject; // 7 Miss Root Sig for Plane Hit Group and Miss int emptyRootIndex = index++; // 7 ExportAssociation emptyRootAssociation = new ExportAssociation(new string[] { RTPipeline.kPlaneChs, RTPipeline.kMissShader }, subobjects[emptyRootIndex]); subobjects[index++] = emptyRootAssociation.subobject; // 8 Associate empty Root Sig to Plane Hit Group and Miss Shader // Bind the payload size to the programs ShaderConfig shaderConfig = new ShaderConfig(sizeof(float) * 2, sizeof(float) * 3); subobjects[index] = shaderConfig.subObject; // 9 Shader Config; int shaderConfigIndex = index++; // 9 string[] shaderExports = new string[] { RTPipeline.kMissShader, RTPipeline.kTriangleChs, RTPipeline.kPlaneChs, RTPipeline.kRayGenShader }; ExportAssociation configAssociation = new ExportAssociation(shaderExports, subobjects[shaderConfigIndex]); subobjects[index++] = configAssociation.subobject; // 10 Associate Shader Config to all shaders and hit groups // Create the pipeline config PipelineConfig config = new PipelineConfig(1); subobjects[index++] = config.suboject; // 11 // Create the global root signature and store the empty signature Structs.GlobalRootSignature root = new Structs.GlobalRootSignature(mpDevice, new RootSignatureDescription()); mpEmptyRootSig = root.pRootSig.RootSignature; subobjects[index++] = root.suboject; // 12 // Create the state StateObjectDescription desc = new StateObjectDescription(StateObjectType.RaytracingPipeline, subobjects); mpPipelineState = mpDevice.CreateStateObject(desc); }
internal ShaderConfig(int maxAttributeSize, int maxPayloadSize) { config = new RaytracingShaderConfig(maxPayloadSize, maxAttributeSize); subObject = new StateSubObject(config); }
internal MyGlobalRootSignature(ID3D12Device5 device, RootSignatureDescription desc) { rootSig = new GlobalRootSignature(); rootSig.RootSignature = device.CreateRootSignature(desc, RootSignatureVersion.Version1); subObject = new StateSubObject(rootSig); }
internal ExportAssociation(string[] ExportNames, StateSubObject subObjectToAssociate) { Association = new SubObjectToExportsAssociation(subObjectToAssociate, ExportNames); SubObject = new StateSubObject(Association); }
internal PipelineConfig(int maxRecursion) { config = new RaytracingPipelineConfig(maxRecursion); SubObject = new StateSubObject(config); }
public SubObjectToExportsAssociation(StateSubObject subObjectToAssociate, params string[] exports) { SubObjectToAssociate = subObjectToAssociate; Exports = exports; }