Пример #1
0
        public CpuDescriptorHandle CreateRTV(ID3D12Device5 pDevice, ID3D12Resource pResource, ID3D12DescriptorHeap pHeap, ref uint usedHeapEntries, Format format)
        {
            RenderTargetViewDescription desc = new RenderTargetViewDescription();

            desc.ViewDimension      = RenderTargetViewDimension.Texture2D;
            desc.Format             = format;
            desc.Texture2D          = new Texture2DRenderTargetView();
            desc.Texture2D.MipSlice = 0;
            CpuDescriptorHandle rtvHandle = pHeap.GetCPUDescriptorHandleForHeapStart();

            rtvHandle.Ptr += usedHeapEntries * pDevice.GetDescriptorHandleIncrementSize(DescriptorHeapType.RenderTargetView);
            usedHeapEntries++;
            pDevice.CreateRenderTargetView(pResource, desc, rtvHandle);
            return(rtvHandle);
        }
Пример #2
0
        public void CreateShaderResources()
        {
            // Create the output resource. The dimensions and format should match the swap-chain
            ResourceDescription resDesc = new ResourceDescription();

            resDesc.DepthOrArraySize  = 1;
            resDesc.Dimension         = ResourceDimension.Texture2D;
            resDesc.Format            = Format.R8G8B8A8_UNorm; // The backbuffer is actually DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, but sRGB formats can't be used with UAVs. We will convert to sRGB ourselves in the shader
            resDesc.Flags             = ResourceFlags.AllowUnorderedAccess;
            resDesc.Height            = mSwapChainRect.Height;
            resDesc.Layout            = TextureLayout.Unknown;
            resDesc.MipLevels         = 1;
            resDesc.SampleDescription = new SampleDescription(1, 0);
            resDesc.Width             = mSwapChainRect.Width;
            mpOutputResource          = mpDevice.CreateCommittedResource(AccelerationStructures.kDefaultHeapProps, HeapFlags.None, resDesc, ResourceStates.CopySource, null); // Starting as copy-source to simplify onFrameRender()

            // Create an SRV/UAV descriptor heap. Need 2 entries - 1 SRV for the scene and 1 UAV for the output
            mpSrvUavHeap = this.context.CreateDescriptorHeap(mpDevice, 2, DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView, true);

            // Create the UAV. Based on the root signature we created it should be the first entry
            UnorderedAccessViewDescription uavDesc = new UnorderedAccessViewDescription();

            uavDesc.ViewDimension = UnorderedAccessViewDimension.Texture2D;
            mpDevice.CreateUnorderedAccessView(mpOutputResource, null, uavDesc, mpSrvUavHeap.GetCPUDescriptorHandleForHeapStart());

            // Create the TLAS SRV right after the UAV. Note that we are using a different SRV desc here
            ShaderResourceViewDescription srvDesc = new ShaderResourceViewDescription();

            srvDesc.ViewDimension                            = ShaderResourceViewDimension.RaytracingAccelerationStructure;
            srvDesc.Shader4ComponentMapping                  = D3D12DefaultShader4ComponentMapping;
            srvDesc.RaytracingAccelerationStructure          = new RaytracingAccelerationStructureShaderResourceView();
            srvDesc.RaytracingAccelerationStructure.Location = mpTopLevelAS.GPUVirtualAddress;
            CpuDescriptorHandle srvHandle = mpSrvUavHeap.GetCPUDescriptorHandleForHeapStart();

            srvHandle.Ptr += mpDevice.GetDescriptorHandleIncrementSize(DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView);
            mpDevice.CreateShaderResourceView(null, srvDesc, srvHandle);
        }
Пример #3
0
        public unsafe void CreateShaderTable()
        {
            /** The shader-table layout is as follows:
             *  Entry 0 - Ray-gen program
             *  Entry 1 - Miss program for the primary ray
             *  Entry 2 - Miss programm for the shadow ray
             *  Entry 3,4 - Hit program for triangle 0 (primary followed by shadow)
             *  Entry 5,6 - Hit program for the plane (primary followed by shadow)
             *  Entry 7,8 - Hit program for triangle 1 (primary followed by shadow)
             *  Entry 9,10 - Hit program for triangle 2 (primary followed by shadow)
             *  All entries in the shader-table must have the same size, so we will choose it base on the largest required entry.
             *  The ray-gen program requires the largest entry - sizeof(program identifier) + 8 bytes for a descriptor-table.
             *  The entry size must be aligned up to D3D12_RAYTRACING_SHADER_RECORD_BYTE_ALIGNMENT
             */

            // Calculate the size and create the buffer
            mShaderTableEntrySize  = D3D12ShaderIdentifierSizeInBytes;
            mShaderTableEntrySize += 8; // the ray-gen's descriptor table
            mShaderTableEntrySize  = align_to(D3D12RaytracingShaderRecordByteAlignment, mShaderTableEntrySize);
            uint shaderTableSize = mShaderTableEntrySize * 11;

            // For simplicity, we create the shader.table on the upload heap. You can also create it on the default heap
            mpShaderTable = this.acs.CreateBuffer(mpDevice, shaderTableSize, ResourceFlags.None, ResourceStates.GenericRead, AccelerationStructures.kUploadHeapProps);

            // Map the buffer
            IntPtr pData;

            pData = mpShaderTable.Map(0, null);

            ID3D12StateObjectProperties pRtsoProps;

            pRtsoProps = mpPipelineState.QueryInterface <ID3D12StateObjectProperties>();

            // Entry 0 - ray-gen program ID and descriptor data
            Unsafe.CopyBlock((void *)pData, (void *)pRtsoProps.GetShaderIdentifier(RTPipeline.kRayGenShader), D3D12ShaderIdentifierSizeInBytes);
            ulong heapStart = (ulong)mpSrvUavHeap.GetGPUDescriptorHandleForHeapStart().Ptr;

            Unsafe.Write <ulong>((pData + (int)D3D12ShaderIdentifierSizeInBytes).ToPointer(), heapStart);

            // Entry 1 - primary ray miss
            pData += (int)mShaderTableEntrySize; // +1 skips ray-gen
            Unsafe.CopyBlock((void *)pData, (void *)pRtsoProps.GetShaderIdentifier(RTPipeline.kMissShader), D3D12ShaderIdentifierSizeInBytes);

            // Entry 2 - shadow-ray miss
            pData += (int)mShaderTableEntrySize;
            Unsafe.CopyBlock((void *)pData, (void *)pRtsoProps.GetShaderIdentifier(RTPipeline.kShadowMiss), D3D12ShaderIdentifierSizeInBytes);

            // Entry 3 - Triangle 0, PRIMARY RAY. ProgramID and constant-buffer data
            pData += (int)mShaderTableEntrySize;
            Unsafe.CopyBlock((void *)pData, (void *)pRtsoProps.GetShaderIdentifier(RTPipeline.kTriHitGroup), D3D12ShaderIdentifierSizeInBytes);
            void *pEntry3 = (pData + (int)D3D12ShaderIdentifierSizeInBytes).ToPointer();

            Unsafe.Write <ulong>(pEntry3, (ulong)mpContantBuffer[0].GPUVirtualAddress);

            // Entry 4 - Triangle 0, shadow ray. ProgramID only
            pData += (int)mShaderTableEntrySize;
            Unsafe.CopyBlock((void *)pData, (void *)pRtsoProps.GetShaderIdentifier(RTPipeline.kShadowHitGroup), D3D12ShaderIdentifierSizeInBytes);

            // Entry 5 - Plane, primary ray. ProgramID only and the TLAS SRV
            pData += (int)mShaderTableEntrySize;
            Unsafe.CopyBlock((void *)pData, (void *)pRtsoProps.GetShaderIdentifier(RTPipeline.kPlaneHitGroup), D3D12ShaderIdentifierSizeInBytes);
            void *pEntry5 = (pData + (int)D3D12ShaderIdentifierSizeInBytes).ToPointer();

            Unsafe.Write <ulong>(pEntry5, heapStart + (ulong)mpDevice.GetDescriptorHandleIncrementSize(DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView)); // The SRV comes directly after the program id

            // Entry 6 - Plane shadow ray
            pData += (int)mShaderTableEntrySize;
            Unsafe.CopyBlock((void *)pData, (void *)pRtsoProps.GetShaderIdentifier(RTPipeline.kShadowHitGroup), D3D12ShaderIdentifierSizeInBytes);

            // Entry 7 - Triangle 1 hit. ProgramID and constant-buffer data
            pData += (int)mShaderTableEntrySize;
            Unsafe.CopyBlock((void *)pData, (void *)pRtsoProps.GetShaderIdentifier(RTPipeline.kTriHitGroup), D3D12ShaderIdentifierSizeInBytes);
            void *pEntry7 = (pData + (int)D3D12ShaderIdentifierSizeInBytes).ToPointer();

            Unsafe.Write <ulong>(pEntry7, (ulong)mpContantBuffer[1].GPUVirtualAddress);

            // Entry 8 - Triangle 1, shadow ray. ProgramID only
            pData += (int)mShaderTableEntrySize;
            Unsafe.CopyBlock((void *)pData, (void *)pRtsoProps.GetShaderIdentifier(RTPipeline.kShadowHitGroup), D3D12ShaderIdentifierSizeInBytes);

            // Entry 9 - Triangle 2 hit. ProgramID and constant-buffer data
            pData += (int)mShaderTableEntrySize;
            Unsafe.CopyBlock((void *)pData, (void *)pRtsoProps.GetShaderIdentifier(RTPipeline.kTriHitGroup), D3D12ShaderIdentifierSizeInBytes);
            void *pEntry9 = (pData + (int)D3D12ShaderIdentifierSizeInBytes).ToPointer();

            Unsafe.Write <ulong>(pEntry9, (ulong)mpContantBuffer[2].GPUVirtualAddress);

            // Entry 10 - Triangle 2, shadow ray. ProgramID only
            pData += (int)mShaderTableEntrySize;
            Unsafe.CopyBlock((void *)pData, (void *)pRtsoProps.GetShaderIdentifier(RTPipeline.kShadowHitGroup), D3D12ShaderIdentifierSizeInBytes);

            // Unmap
            mpShaderTable.Unmap(0, null);
        }
Пример #4
0
        public void CreateShaderResources()
        {
            // Create the output resource. The dimensions and format should match the swap-chain
            ResourceDescription resDesc = new ResourceDescription();

            resDesc.DepthOrArraySize  = 1;
            resDesc.Dimension         = ResourceDimension.Texture2D;
            resDesc.Format            = Format.R8G8B8A8_UNorm; // The backbuffer is actually DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, but sRGB formats can't be used with UAVs. We will convert to sRGB ourselves in the shader
            resDesc.Flags             = ResourceFlags.AllowUnorderedAccess;
            resDesc.Height            = mSwapChainRect.Height;
            resDesc.Layout            = TextureLayout.Unknown;
            resDesc.MipLevels         = 1;
            resDesc.SampleDescription = new SampleDescription(1, 0);
            resDesc.Width             = mSwapChainRect.Width;
            mpOutputResource          = mpDevice.CreateCommittedResource(AccelerationStructures.kDefaultHeapProps, HeapFlags.None, resDesc, ResourceStates.CopySource, null); // Starting as copy-source to simplify onFrameRender()

            // Create an SRV/UAV/VertexSRV/IndexSRV descriptor heap. Need 5 entries - 1 SRV for the scene, 1 UAV for the output, 1 SRV for VertexBuffer, 1 SRV for IndexBuffer, 1 SceneContantBuffer, 1 primitiveConstantBuffer
            mpSrvUavHeap = this.context.CreateDescriptorHeap(mpDevice, 6, DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView, true);

            // Create the UAV. Based on the root signature we created it should be the first entry
            UnorderedAccessViewDescription uavDesc = new UnorderedAccessViewDescription();

            uavDesc.ViewDimension = UnorderedAccessViewDimension.Texture2D;
            mpDevice.CreateUnorderedAccessView(mpOutputResource, null, uavDesc, mpSrvUavHeap.GetCPUDescriptorHandleForHeapStart());

            // Create the TLAS SRV right after the UAV. Note that we are using a different SRV desc here
            ShaderResourceViewDescription srvDesc = new ShaderResourceViewDescription();

            srvDesc.ViewDimension                            = ShaderResourceViewDimension.RaytracingAccelerationStructure;
            srvDesc.Shader4ComponentMapping                  = D3D12DefaultShader4ComponentMapping;
            srvDesc.RaytracingAccelerationStructure          = new RaytracingAccelerationStructureShaderResourceView();
            srvDesc.RaytracingAccelerationStructure.Location = mpTopLevelAS.GPUVirtualAddress;
            CpuDescriptorHandle srvHandle = mpSrvUavHeap.GetCPUDescriptorHandleForHeapStart();

            srvHandle.Ptr += mpDevice.GetDescriptorHandleIncrementSize(DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView);
            mpDevice.CreateShaderResourceView(null, srvDesc, srvHandle);

            // Index SRV
            var indexSRVDesc = new ShaderResourceViewDescription()
            {
                ViewDimension           = ShaderResourceViewDimension.Buffer,
                Shader4ComponentMapping = D3D12DefaultShader4ComponentMapping,
                Format = Format.R32_Typeless,
                Buffer =
                {
                    NumElements         = (int)(this.acs.IndexCount * 2 / 4),
                    Flags               = BufferShaderResourceViewFlags.Raw,
                    StructureByteStride =                                  0,
                }
            };

            srvHandle.Ptr += mpDevice.GetDescriptorHandleIncrementSize(DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView);
            indexSRVHandle = srvHandle;
            mpDevice.CreateShaderResourceView(this.acs.IndexBuffer, indexSRVDesc, indexSRVHandle);

            // Vertex SRV
            var vertexSRVDesc = new ShaderResourceViewDescription()
            {
                ViewDimension           = ShaderResourceViewDimension.Buffer,
                Shader4ComponentMapping = D3D12DefaultShader4ComponentMapping,
                Format = Format.Unknown,
                Buffer =
                {
                    NumElements         = (int)this.acs.VertexCount,
                    Flags               = BufferShaderResourceViewFlags.None,
                    StructureByteStride = Unsafe.SizeOf <VertexPositionNormalTangentTexture>(),
                }
            };

            srvHandle.Ptr  += mpDevice.GetDescriptorHandleIncrementSize(DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView);
            vertexSRVHandle = srvHandle;
            mpDevice.CreateShaderResourceView(this.acs.VertexBuffer, vertexSRVDesc, vertexSRVHandle);

            // CB Scene
            Vector3   cameraPosition = new Vector3(0, 1, -7);
            Matrix4x4 view           = Matrix4x4.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.UnitY);
            Matrix4x4 proj           = Matrix4x4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)mSwapChainRect.Width / mSwapChainRect.Height, 0.1f, 1000f);
            Matrix4x4 viewProj       = Matrix4x4.Multiply(view, proj);

            Matrix4x4.Invert(viewProj, out Matrix4x4 projectionToWorld);
            SceneConstantBuffer sceneConstantBuffer = new SceneConstantBuffer()
            {
                projectionToWorld = Matrix4x4.Transpose(projectionToWorld),
                cameraPosition    = cameraPosition,
                lightPosition     = new Vector3(0.0f, 1.0f, -2.0f),
                lightDiffuseColor = new Vector4(0.5f, 0.5f, 0.5f, 1.0f),
                lightAmbientColor = new Vector4(0.1f, 0.1f, 0.1f, 1.0f),
                backgroundColor   = new Vector4(0.4f, 0.6f, 0.2f, 1.0f),
                MaxRecursionDepth = 4,
            };

            sceneCB = this.acs.CreateBuffer(mpDevice, (uint)Unsafe.SizeOf <SceneConstantBuffer>(), ResourceFlags.None, ResourceStates.GenericRead, AccelerationStructures.kUploadHeapProps);
            IntPtr pData;

            pData = sceneCB.Map(0, null);
            Helpers.MemCpy(pData, sceneConstantBuffer, (uint)Unsafe.SizeOf <SceneConstantBuffer>());
            sceneCB.Unmap(0, null);

            var sceneCBV = new ConstantBufferViewDescription()
            {
                BufferLocation = sceneCB.GPUVirtualAddress,
                SizeInBytes    = (Unsafe.SizeOf <SceneConstantBuffer>() + 255) & ~255,
            };

            srvHandle.Ptr += mpDevice.GetDescriptorHandleIncrementSize(DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView);
            sceneCBVHandle = srvHandle;
            mpDevice.CreateConstantBufferView(sceneCBV, sceneCBVHandle);

            // CB Primitive
            PrimitiveConstantBuffer primitiveConstantBuffer = new PrimitiveConstantBuffer()
            {
                diffuseColor     = new Vector4(0.8f, 0f, 0f, 1.0f),
                inShadowRadiance = 0.35f,
                diffuseCoef      = 0.1f,
                specularCoef     = 0.7f,
                specularPower    = 50,
                reflectanceCoef  = 0.7f,
            };

            ID3D12Resource primitiveCB = this.acs.CreateBuffer(mpDevice, (uint)Unsafe.SizeOf <PrimitiveConstantBuffer>(), ResourceFlags.None, ResourceStates.GenericRead, AccelerationStructures.kUploadHeapProps);
            IntPtr         pData2;

            pData2 = primitiveCB.Map(0, null);
            Helpers.MemCpy(pData2, primitiveConstantBuffer, (uint)Unsafe.SizeOf <PrimitiveConstantBuffer>());
            primitiveCB.Unmap(0, null);

            var primitiveCBV = new ConstantBufferViewDescription()
            {
                BufferLocation = primitiveCB.GPUVirtualAddress,
                SizeInBytes    = (Unsafe.SizeOf <PrimitiveConstantBuffer>() + 255) & ~255,
            };

            srvHandle.Ptr += mpDevice.GetDescriptorHandleIncrementSize(DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView);
            var primitiveCBVHandle = srvHandle;

            mpDevice.CreateConstantBufferView(primitiveCBV, primitiveCBVHandle);
        }
Пример #5
0
        public void CreateShaderResources()
        {
            // Create the output resource. The dimensions and format should match the swap-chain
            ResourceDescription resDesc = new ResourceDescription();

            resDesc.DepthOrArraySize  = 1;
            resDesc.Dimension         = ResourceDimension.Texture2D;
            resDesc.Format            = Format.R8G8B8A8_UNorm; // The backbuffer is actually DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, but sRGB formats can't be used with UAVs. We will convert to sRGB ourselves in the shader
            resDesc.Flags             = ResourceFlags.AllowUnorderedAccess;
            resDesc.Height            = mSwapChainRect.Height;
            resDesc.Layout            = TextureLayout.Unknown;
            resDesc.MipLevels         = 1;
            resDesc.SampleDescription = new SampleDescription(1, 0);
            resDesc.Width             = mSwapChainRect.Width;
            mpOutputResource          = mpDevice.CreateCommittedResource(AccelerationStructures.kDefaultHeapProps, HeapFlags.None, resDesc, ResourceStates.CopySource, null); // Starting as copy-source to simplify onFrameRender()

            // Create an SRV/UAV/VertexSRV/IndexSRV descriptor heap. Need 5 entries - 1 SRV for the scene, 1 UAV for the output, 1 SRV for VertexBuffer, 1 SRV for IndexBuffer, 1 SRV for texture
            mpSrvUavHeap = this.context.CreateDescriptorHeap(mpDevice, 5, DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView, true);

            // Create the UAV. Based on the root signature we created it should be the first entry
            UnorderedAccessViewDescription uavDesc = new UnorderedAccessViewDescription();

            uavDesc.ViewDimension = UnorderedAccessViewDimension.Texture2D;
            mpDevice.CreateUnorderedAccessView(mpOutputResource, null, uavDesc, mpSrvUavHeap.GetCPUDescriptorHandleForHeapStart());

            // Create the TLAS SRV right after the UAV. Note that we are using a different SRV desc here
            ShaderResourceViewDescription srvDesc = new ShaderResourceViewDescription();

            srvDesc.ViewDimension                            = ShaderResourceViewDimension.RaytracingAccelerationStructure;
            srvDesc.Shader4ComponentMapping                  = D3D12DefaultShader4ComponentMapping;
            srvDesc.RaytracingAccelerationStructure          = new RaytracingAccelerationStructureShaderResourceView();
            srvDesc.RaytracingAccelerationStructure.Location = mpTopLevelAS.GPUVirtualAddress;
            CpuDescriptorHandle srvHandle = mpSrvUavHeap.GetCPUDescriptorHandleForHeapStart();

            srvHandle.Ptr += mpDevice.GetDescriptorHandleIncrementSize(DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView);
            mpDevice.CreateShaderResourceView(null, srvDesc, srvHandle);

            // Index SRV
            var indexSRVDesc = new ShaderResourceViewDescription()
            {
                ViewDimension           = ShaderResourceViewDimension.Buffer,
                Shader4ComponentMapping = D3D12DefaultShader4ComponentMapping,
                Format = Format.R32_Typeless,
                Buffer =
                {
                    NumElements         = (int)(this.acs.IndexCount * 2 / 4),
                    Flags               = BufferShaderResourceViewFlags.Raw,
                    StructureByteStride =                                  0,
                }
            };

            srvHandle.Ptr += mpDevice.GetDescriptorHandleIncrementSize(DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView);
            indexSRVHandle = srvHandle;
            mpDevice.CreateShaderResourceView(this.acs.IndexBuffer, indexSRVDesc, indexSRVHandle);

            // Vertex SRV
            var vertexSRVDesc = new ShaderResourceViewDescription()
            {
                ViewDimension           = ShaderResourceViewDimension.Buffer,
                Shader4ComponentMapping = D3D12DefaultShader4ComponentMapping,
                Format = Format.Unknown,
                Buffer =
                {
                    NumElements         = (int)this.acs.VertexCount,
                    Flags               = BufferShaderResourceViewFlags.None,
                    StructureByteStride = Unsafe.SizeOf <VertexPositionNormalTangentTexture>(),
                }
            };

            srvHandle.Ptr  += mpDevice.GetDescriptorHandleIncrementSize(DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView);
            vertexSRVHandle = srvHandle;
            mpDevice.CreateShaderResourceView(this.acs.VertexBuffer, vertexSRVDesc, vertexSRVHandle);

            // Texture
            var image       = TextureHelper.Load("GLTF/Default_albedo.jpg");
            var textureDesc = ResourceDescription.Texture2D(image.Format, (int)image.Width, (int)image.Height);

            this.texture = this.mpDevice.CreateCommittedResource(new HeapProperties(HeapType.Default), HeapFlags.None, textureDesc, ResourceStates.CopyDestination);

            // Create the GPU upload buffer.
            var textureUploadHeap = mpDevice.CreateCommittedResource(new HeapProperties(CpuPageProperty.WriteBack, MemoryPool.L0), HeapFlags.None, textureDesc, ResourceStates.GenericRead);

            // Copy data to the intermediate upload heap and then schedule a copy
            // from the upload heap to the Texture2D.
            byte[] textureData = image.Data;

            var handle = GCHandle.Alloc(textureData, GCHandleType.Pinned);
            var ptr    = Marshal.UnsafeAddrOfPinnedArrayElement(textureData, 0);

            textureUploadHeap.WriteToSubresource(0, null, ptr, (int)(image.TexturePixelSize * image.Width), textureData.Length);
            handle.Free();

            mpCmdList.CopyTextureRegion(new TextureCopyLocation(texture, 0), 0, 0, 0, new TextureCopyLocation(textureUploadHeap, 0), null);

            mpCmdList.ResourceBarrierTransition(this.texture, ResourceStates.CopyDestination, ResourceStates.PixelShaderResource);

            // Describe and create a SRV for the texture.
            var textureSRVDesc = new ShaderResourceViewDescription
            {
                Shader4ComponentMapping = D3D12DefaultShader4ComponentMapping,
                Format        = textureDesc.Format,
                ViewDimension = ShaderResourceViewDimension.Texture2D,
                Texture2D     = { MipLevels = 1 },
            };

            srvHandle.Ptr   += mpDevice.GetDescriptorHandleIncrementSize(DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView);
            textureSRVHandle = srvHandle;
            this.mpDevice.CreateShaderResourceView(this.texture, textureSRVDesc, textureSRVHandle);
        }