Sfoglia il codice sorgente

fix some compilation problems

Kolja Strohm 4 settimane fa
parent
commit
c8d21ffde8
5 ha cambiato i file con 106 aggiunte e 87 eliminazioni
  1. 13 4
      Array.h
  2. 5 6
      DX12GraphicsApi.cpp
  3. 6 4
      DX12GraphicsApi.h
  4. 73 66
      DX12Shader.h
  5. 9 7
      HashMap.h

+ 13 - 4
Array.h

@@ -201,14 +201,17 @@ namespace Framework
                 newEntry->var = current->var;
                 newEntry->set = current->set;
                 newEntry->next = current->next;
-                if (!current->next)
+                if (!current->next && onLastChanged)
                 {
                     (*onLastChanged)(newEntry);
                 }
                 current->var = val;
                 current->set = true;
                 current->next = newEntry;
-                (*onSizeChanged)(1);
+                if (onSizeChanged)
+                {
+                    (*onSizeChanged)(1);
+                }
             }
             else
             {
@@ -274,7 +277,10 @@ namespace Framework
                 current->next = current->next->next;
             else
             {
-                (*onLastChanged)(current);
+                if (onLastChanged)
+                {
+                    (*onLastChanged)(current);
+                }
                 current->next = 0;
             }
             if (del)
@@ -283,7 +289,10 @@ namespace Framework
                 del->next = 0;
                 delete del;
             }
-            (*onSizeChanged)(-1);
+            if (onSizeChanged)
+            {
+                (*onSizeChanged)(-1);
+            }
         }
     };
 

+ 5 - 6
DX12GraphicsApi.cpp

@@ -272,13 +272,13 @@ void Framework::DirectX12::initializePipeline()
         pipeline->addShader(missShader);
 
         DX12Shader* hitShader = new DX12Shader(
-            DX12DefaultMissShaderBytes, sizeof(DX12DefaultMissShaderBytes));
+            DX12DefaultHitShaderBytes, sizeof(DX12DefaultHitShaderBytes));
         // ClosestHit from Hit.hlsl
         DX12ShaderFunction* closestHitFunction
             = new DX12ShaderFunction("ClosestHit",
                 new DX12ShaderSignature(),
                 DX12_SHADER_FUNCTION_TYPE_CLOSEST_HIT);
-        missShader->addFunction(closestHitFunction);
+        hitShader->addFunction(closestHitFunction);
         pipeline->addShader(hitShader);
 
         defaultHitGroup = new DX12ShaderHitGroup("HitGroup");
@@ -555,7 +555,7 @@ void DirectX12::initialize(
     DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {};
     swapChainDesc.Width = backBufferSize.x;
     swapChainDesc.Height = backBufferSize.y;
-    swapChainDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+    swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
     swapChainDesc.Stereo = FALSE;
     swapChainDesc.SampleDesc = {1, 0};
     swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
@@ -621,6 +621,7 @@ void DirectX12::initialize(
     renderTargetImage->newImage(backBufferSize.x, backBufferSize.y, 0);
     defaultRenderTarget = dynamic_cast<DX12Texture*>(
         createOrGetTexture("_f_RenderTarget", renderTargetImage, GPU_TO_RAM));
+    defaultRenderTarget->updateTextur();
 
     viewPort = new D3D12_VIEWPORT();
     viewPort->Width = (float)this->backBufferSize.x;
@@ -770,9 +771,7 @@ void DirectX12::beginFrame(bool fill2D, bool fill3D, int fillColor)
     barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;
     barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET;
     barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
-
-    // TODO
-    // directCommandQueue->getCommandList()->ResourceBarrier(1, &barrier);
+    directCommandQueue->zCommandList()->ResourceBarrier(1, &barrier);
 
     if (fill2D) uiTexture->zImage()->setColor(fillColor);
 

+ 6 - 4
DX12GraphicsApi.h

@@ -69,6 +69,8 @@ namespace Framework
         int lastTLASId;
         int lastModelId;
         DX12Texture* defaultRenderTarget;
+
+    protected:
         DX12Pipeline* pipeline;
         DX12GlobalDescriptorHeap* globalDescriptorHeap;
         DX12ShaderHitGroup* defaultHitGroup;
@@ -80,13 +82,13 @@ namespace Framework
         DLLEXPORT DirectX12();
         DLLEXPORT ~DirectX12();
 
-    private:
+    protected:
         DLLEXPORT void updateBottomLevelAccelerationStructure();
         DLLEXPORT void renderKamera(
             Cam3D* zKamera, DX12Texture* zTarget, bool guiVisible);
-        DLLEXPORT void initializePipeline();
-        DLLEXPORT void initializeGlobalDescriptorHeap();
-        DLLEXPORT void fillShaderBindingTable(
+        DLLEXPORT virtual void initializePipeline();
+        DLLEXPORT virtual void initializeGlobalDescriptorHeap();
+        DLLEXPORT virtual void fillShaderBindingTable(
             DX12ShaderBindingTable* zShaderBindingTable,
             Model3D* zModel,
             int objectIndex);

+ 73 - 66
DX12Shader.h

@@ -44,8 +44,8 @@ namespace Framework
         int shaderBindingTableParamCount;
 
     public:
-        DX12ShaderSignature();
-        ~DX12ShaderSignature();
+        DLLEXPORT DX12ShaderSignature();
+        DLLEXPORT ~DX12ShaderSignature();
         /**
          * for each datastructure with : register(...) in the shader code,
          * either this function or addRegisterUsageLinkedToDescriptorHeap must
@@ -62,7 +62,7 @@ namespace Framework
          * call to createSignature() and should be used to fill the shader
          * binding table with the correct GPU addresses of the resources.
          */
-        int* addRegisterUsageLinkedToShaderBindingTable(
+        DLLEXPORT int* addRegisterUsageLinkedToShaderBindingTable(
             DX12ShaderRegister registerType,
             int registerIndex,
             int spaceIndex = 0);
@@ -84,19 +84,20 @@ namespace Framework
          * \param spaceIndex the optional space index e.g. 3 for : register(b1,
          * space3)
          */
-        void addRegisterUsageLinkedToDescriptorHeap(int descriptorHeapIndex,
+        DLLEXPORT void addRegisterUsageLinkedToDescriptorHeap(
+            int descriptorHeapIndex,
             DX12ShaderRegister registerType,
             int registerIndex,
             int spaceIndex = 0);
         /**
          * Creates the root signature.
          */
-        void createSignature(ID3D12Device5* zDevice,
+        DLLEXPORT void createSignature(ID3D12Device5* zDevice,
             PFN_D3D12_SERIALIZE_ROOT_SIGNATURE pfnD3D12SerializeRootSignature);
-        ID3D12RootSignature* zSignature() const;
-        const Array<DX12ShaderRegisterUsage*>&
+        DLLEXPORT ID3D12RootSignature* zSignature() const;
+        DLLEXPORT const Array<DX12ShaderRegisterUsage*>&
         getDescriptorHeapBindings() const;
-        int gerShaderBindingTableParamCount() const;
+        DLLEXPORT int gerShaderBindingTableParamCount() const;
     };
 
     enum DX12ShaderFunctionType
@@ -118,14 +119,14 @@ namespace Framework
         DX12ShaderFunctionType functionType;
 
     public:
-        DX12ShaderFunction(const Text& functionName,
+        DLLEXPORT DX12ShaderFunction(const Text& functionName,
             DX12ShaderSignature* signature,
             DX12ShaderFunctionType functionType);
-        ~DX12ShaderFunction();
-        const Text& getFunctionName() const;
-        DX12ShaderSignature* zSignature() const;
-        D3D12_EXPORT_DESC* zExportDesc() const;
-        DX12ShaderFunctionType getFunctionType() const;
+        DLLEXPORT ~DX12ShaderFunction();
+        DLLEXPORT const Text& getFunctionName() const;
+        DLLEXPORT DX12ShaderSignature* zSignature() const;
+        DLLEXPORT D3D12_EXPORT_DESC* zExportDesc() const;
+        DLLEXPORT DX12ShaderFunctionType getFunctionType() const;
     };
 
     class DX12Shader : public ReferenceCounter
@@ -137,13 +138,14 @@ namespace Framework
         D3D12_DXIL_LIBRARY_DESC* libraryDesc;
 
     public:
-        DX12Shader(const unsigned char* shaderBytes, int shaderBytesSize);
-        ~DX12Shader();
-        void addFunction(DX12ShaderFunction* function);
-        int getShaderBytesSize() const;
-        const unsigned char* getShaderBytes() const;
-        const RCArray<DX12ShaderFunction>& getFunctions() const;
-        D3D12_DXIL_LIBRARY_DESC* zLibraryDesc() const;
+        DLLEXPORT DX12Shader(
+            const unsigned char* shaderBytes, int shaderBytesSize);
+        DLLEXPORT ~DX12Shader();
+        DLLEXPORT void addFunction(DX12ShaderFunction* function);
+        DLLEXPORT int getShaderBytesSize() const;
+        DLLEXPORT const unsigned char* getShaderBytes() const;
+        DLLEXPORT const RCArray<DX12ShaderFunction>& getFunctions() const;
+        DLLEXPORT D3D12_DXIL_LIBRARY_DESC* zLibraryDesc() const;
     };
 
     class DX12ShaderHitGroup : public ReferenceCounter
@@ -158,23 +160,24 @@ namespace Framework
         D3D12_HIT_GROUP_DESC* hitGroupDesc;
 
     public:
-        DX12ShaderHitGroup(const Text name);
-        ~DX12ShaderHitGroup();
-        void setClosestHitShaderFunction(
+        DLLEXPORT DX12ShaderHitGroup(const Text name);
+        DLLEXPORT ~DX12ShaderHitGroup();
+        DLLEXPORT void setClosestHitShaderFunction(
             DX12ShaderFunction* zClosestHitShaderFunction);
-        void setAnyHitShaderFunction(DX12ShaderFunction* zAnyHitShaderFunction);
-        void setIntersectionShaderFunction(
+        DLLEXPORT void setAnyHitShaderFunction(
+            DX12ShaderFunction* zAnyHitShaderFunction);
+        DLLEXPORT void setIntersectionShaderFunction(
             DX12ShaderFunction* zIntersectionShaderFunction);
-        void setPayloadSize(int payloadSize);
-        void setAttributeSize(int attributeSize);
-        const Text& getName() const;
-        DX12ShaderFunction* zClosestHitShaderFunction() const;
-        DX12ShaderFunction* zAnyHitShaderFunction() const;
-        DX12ShaderFunction* zIntersectionShaderFunction() const;
-        int getPayloadSize() const;
-        int getAttributeSize() const;
-        D3D12_HIT_GROUP_DESC* zHitGroupDesc() const;
-        DX12ShaderSignature* zSignature() const;
+        DLLEXPORT void setPayloadSize(int payloadSize);
+        DLLEXPORT void setAttributeSize(int attributeSize);
+        DLLEXPORT const Text& getName() const;
+        DLLEXPORT DX12ShaderFunction* zClosestHitShaderFunction() const;
+        DLLEXPORT DX12ShaderFunction* zAnyHitShaderFunction() const;
+        DLLEXPORT DX12ShaderFunction* zIntersectionShaderFunction() const;
+        DLLEXPORT int getPayloadSize() const;
+        DLLEXPORT int getAttributeSize() const;
+        DLLEXPORT D3D12_HIT_GROUP_DESC* zHitGroupDesc() const;
+        DLLEXPORT DX12ShaderSignature* zSignature() const;
     };
 
     class DX12ShaderBindingTable;
@@ -192,20 +195,20 @@ namespace Framework
         int maxRecursionDepth;
 
     public:
-        DX12Pipeline();
-        ~DX12Pipeline();
-        void addShader(DX12Shader* shader);
-        void addHitGroup(DX12ShaderHitGroup* hitGroup);
-        void setMaxRecursionDepth(int maxRecursionDepth);
-        void createPipelineState(ID3D12Device5* zDevice,
+        DLLEXPORT DX12Pipeline();
+        DLLEXPORT ~DX12Pipeline();
+        DLLEXPORT void addShader(DX12Shader* shader);
+        DLLEXPORT void addHitGroup(DX12ShaderHitGroup* hitGroup);
+        DLLEXPORT void setMaxRecursionDepth(int maxRecursionDepth);
+        DLLEXPORT void createPipelineState(ID3D12Device5* zDevice,
             PFN_D3D12_SERIALIZE_ROOT_SIGNATURE pfnD3D12SerializeRootSignature);
-        ID3D12StateObject* zPipelineState() const;
-        DX12ShaderBindingTable* createShaderBindingTable();
-        DX12GlobalDescriptorHeap* createGlobalDescriptorHeap();
-        const RCArray<DX12Shader>& getShaders() const;
-        const Array<const DX12ShaderFunction*>&
+        DLLEXPORT ID3D12StateObject* zPipelineState() const;
+        DLLEXPORT DX12ShaderBindingTable* createShaderBindingTable();
+        DLLEXPORT DX12GlobalDescriptorHeap* createGlobalDescriptorHeap();
+        DLLEXPORT const RCArray<DX12Shader>& getShaders() const;
+        DLLEXPORT const Array<const DX12ShaderFunction*>&
         getFunctionsWithoutHitGroups() const;
-        const RCArray<DX12ShaderHitGroup>& getHitGroups() const;
+        DLLEXPORT const RCArray<DX12ShaderHitGroup>& getHitGroups() const;
     }; // namespace Framework
 
     struct DX12ShaderRegisterInput
@@ -228,15 +231,18 @@ namespace Framework
         ~DX12GlobalDescriptorHeap();
 
     private:
-        void addInput(DX12ShaderRegister type, ReferenceCounter* inputResource);
+        DLLEXPORT void addInput(
+            DX12ShaderRegister type, ReferenceCounter* inputResource);
 
     public:
-        void addTextureInput(DX12ShaderRegister type, Texture* zTexture);
-        void addBufferInput(DX12ShaderRegister type, DXBuffer* zBuffer);
-        void addTLASInput(DX12ShaderRegister type, DX12TLAS* zTLAS);
-        void updateDescriptorHeap(ID3D12Device5* zDevice);
-        DX12Pipeline* zPipeline() const;
-        ID3D12DescriptorHeap* zDescriptorHeap() const;
+        DLLEXPORT void addTextureInput(
+            DX12ShaderRegister type, Texture* zTexture);
+        DLLEXPORT void addBufferInput(
+            DX12ShaderRegister type, DXBuffer* zBuffer);
+        DLLEXPORT void addTLASInput(DX12ShaderRegister type, DX12TLAS* zTLAS);
+        DLLEXPORT void updateDescriptorHeap(ID3D12Device5* zDevice);
+        DLLEXPORT DX12Pipeline* zPipeline() const;
+        DLLEXPORT ID3D12DescriptorHeap* zDescriptorHeap() const;
     };
 
     class DX12ShaderBindingTable : public ReferenceCounter
@@ -260,14 +266,14 @@ namespace Framework
         ID3D12StateObjectProperties* stateObjectProperties;
 
     public:
-        DX12ShaderBindingTable(DX12Pipeline* pipeline);
-        ~DX12ShaderBindingTable();
-        void setGlobalDescriptorHeap(
+        DLLEXPORT DX12ShaderBindingTable(DX12Pipeline* pipeline);
+        DLLEXPORT ~DX12ShaderBindingTable();
+        DLLEXPORT void setGlobalDescriptorHeap(
             DX12GlobalDescriptorHeap* zGlobalDescriptorHeap);
-        void startUpdate();
+        DLLEXPORT void startUpdate();
 
     private:
-        void set(int index, void* data, int size);
+        DLLEXPORT void set(int index, void* data, int size);
 
     public:
         /**
@@ -284,7 +290,7 @@ namespace Framework
          * table for this input. This is usually the GPU address of a buffer or
          * texture.
          */
-        void setShaderInput(DX12ShaderFunction* zFunction,
+        DLLEXPORT void setShaderInput(DX12ShaderFunction* zFunction,
             int* offsetPointer,
             __int64 gpuAddress);
         /**
@@ -298,7 +304,7 @@ namespace Framework
          * index can be used to set the inputs for this hit group by calling
          * setHitGroupShaderInput.
          */
-        int addHitGroup(DX12ShaderHitGroup* zHitGroup);
+        DLLEXPORT int addHitGroup(DX12ShaderHitGroup* zHitGroup);
         /**
          * sets a specific input for a previously added hitgroup.
          *
@@ -312,10 +318,11 @@ namespace Framework
          * table for this input. This is usually the GPU address of a buffer or
          * texture.
          */
-        void setHitGroupShaderInput(
+        DLLEXPORT void setHitGroupShaderInput(
             int hitGroupOffset, int* offsetPointer, __int64 gpuAddress);
-        void endUpdate(ID3D12Device5* zDevice);
-        void fillDispatchRaysDesc(D3D12_DISPATCH_RAYS_DESC* dispatchRaysDesc);
-        DX12Pipeline* zPipeline() const;
+        DLLEXPORT void endUpdate(ID3D12Device5* zDevice);
+        DLLEXPORT void fillDispatchRaysDesc(
+            D3D12_DISPATCH_RAYS_DESC* dispatchRaysDesc);
+        DLLEXPORT DX12Pipeline* zPipeline() const;
     };
 } // namespace Framework

+ 9 - 7
HashMap.h

@@ -53,7 +53,7 @@ namespace Framework
                        || buckets[bucketIndex]->getEntryCount() == 0))
             {
                 bucketIndex++;
-                iterator = ArrayIterator<MapEntry<K, V>>(0, 0);
+                iterator = ArrayIterator<MapEntry<K, V>>(0, 0, 0, 0);
             }
             if (bucketIndex < bucketCount)
             {
@@ -61,7 +61,7 @@ namespace Framework
             }
             else
             {
-                this->iterator = ArrayIterator<MapEntry<K, V>>(0, 0);
+                this->iterator = ArrayIterator<MapEntry<K, V>>(0, 0, 0, 0);
                 this->bucketIndex = 0;
                 this->buckets = 0;
                 this->bucketCount = 0;
@@ -116,7 +116,7 @@ namespace Framework
                 return MapIterator(buckets,
                     bucketCount,
                     bucketIndex + 1,
-                    ArrayIterator<MapEntry<K, V>>(0, 0));
+                    ArrayIterator<MapEntry<K, V>>(0, 0, 0, 0));
         }
 
         operator bool()
@@ -151,7 +151,7 @@ namespace Framework
                     this->iterator = buckets[bucketIndex]->begin();
                 else
                 {
-                    this->iterator = ArrayIterator<MapEntry<K, V>>(0, 0);
+                    this->iterator = ArrayIterator<MapEntry<K, V>>(0, 0, 0, 0);
                     this->bucketIndex = 0;
                     this->buckets = 0;
                     this->bucketCount = 0;
@@ -323,14 +323,16 @@ namespace Framework
 
         MapIterator<K, V> begin()
         {
-            return MapIterator<K, V>(
-                buckets, bucketCount, 0, ArrayIterator<MapEntry<K, V>>(0, 0));
+            return MapIterator<K, V>(buckets,
+                bucketCount,
+                0,
+                ArrayIterator<MapEntry<K, V>>(0, 0, 0, 0));
         }
 
         MapIterator<K, V> end()
         {
             return MapIterator<K, V>(
-                0, 0, 0, ArrayIterator<MapEntry<K, V>>(0, 0));
+                0, 0, 0, ArrayIterator<MapEntry<K, V>>(0, 0, 0, 0));
         }
     };
 } // namespace Framework