-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f55198c
commit 5b0e345
Showing
14 changed files
with
335 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (C) 2020 Pham Hong Duc | ||
// This file is part of the "Skylicht Engine" | ||
// Upgrade GPU Compute Shader feature | ||
|
||
#ifndef __IRR_IRW_BUFFER_H_INCLUDED__ | ||
#define __IRR_IRW_BUFFER_H_INCLUDED__ | ||
|
||
#include "IrrCompileConfig.h" | ||
|
||
#include "IReferenceCounted.h" | ||
#include "IImage.h" | ||
#include "dimension2d.h" | ||
#include "EDriverTypes.h" | ||
#include "path.h" | ||
#include "matrix4.h" | ||
|
||
namespace irr | ||
{ | ||
namespace video | ||
{ | ||
class IRWBuffer : public virtual IReferenceCounted | ||
{ | ||
public: | ||
IRWBuffer(ECOLOR_FORMAT format, u32 numElements) : | ||
DriverType(EDT_NULL), | ||
Format(format), | ||
NumElements(numElements) | ||
{ | ||
} | ||
|
||
E_DRIVER_TYPE getDriverType() const { return DriverType; }; | ||
|
||
protected: | ||
|
||
E_DRIVER_TYPE DriverType; | ||
ECOLOR_FORMAT Format; | ||
u32 NumElements; | ||
}; | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright (C) 2020 Pham Hong Duc | ||
// This file is part of the "Skylicht Engine" | ||
// Upgrade GPU Compute Shader feature | ||
|
||
#include "pch.h" | ||
#include "IrrCompileConfig.h" | ||
#include "CD3D11Driver.h" | ||
#include "CD3D11RWBuffer.h" | ||
|
||
#ifdef _IRR_COMPILE_WITH_DIRECT3D_11_ | ||
|
||
#define _IRR_DONT_DO_MEMORY_DEBUGGING_HERE | ||
|
||
#include "irrOS.h" | ||
|
||
namespace irr | ||
{ | ||
namespace video | ||
{ | ||
CD3D11RWBuffer::CD3D11RWBuffer(CD3D11Driver *driver, ECOLOR_FORMAT format, u32 numElements) : | ||
IRWBuffer(format, numElements), | ||
Driver(driver) | ||
{ | ||
DriverType = EDT_DIRECT3D11; | ||
|
||
D3DFormat = Driver->getD3DFormatFromColorFormat(format); | ||
u32 bytePerPixel = Driver->getBitsPerPixel(D3DFormat) / 8; | ||
|
||
Device = driver->getExposedVideoData().D3D11.D3DDev11; | ||
if (Device) | ||
{ | ||
Device->AddRef(); | ||
Device->GetImmediateContext(&Context); | ||
} | ||
|
||
D3D11_BUFFER_DESC bufferDesc; | ||
bufferDesc.ByteWidth = bytePerPixel * numElements; | ||
bufferDesc.Usage = D3D11_USAGE_DEFAULT; | ||
bufferDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_UNORDERED_ACCESS; | ||
bufferDesc.CPUAccessFlags = 0; | ||
bufferDesc.MiscFlags = 0; | ||
bufferDesc.StructureByteStride = 0; | ||
Device->CreateBuffer(&bufferDesc, NULL, &Buffer); | ||
|
||
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; | ||
srvDesc.Format = D3DFormat; | ||
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER; | ||
srvDesc.Buffer.ElementOffset = 0; | ||
srvDesc.Buffer.ElementWidth = numElements; | ||
Device->CreateShaderResourceView(Buffer, &srvDesc, &SRView); | ||
|
||
D3D11_UNORDERED_ACCESS_VIEW_DESC uavDesc; | ||
uavDesc.Format = D3DFormat; | ||
uavDesc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER; | ||
uavDesc.Buffer.FirstElement = 0; | ||
uavDesc.Buffer.Flags = 0; | ||
uavDesc.Buffer.NumElements = numElements; | ||
Device->CreateUnorderedAccessView(Buffer, &uavDesc, &UAView); | ||
} | ||
|
||
CD3D11RWBuffer::~CD3D11RWBuffer() | ||
{ | ||
SRView->Release(); | ||
UAView->Release(); | ||
Buffer->Release(); | ||
|
||
Context->Release(); | ||
Device->Release(); | ||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (C) 2020 Pham Hong Duc | ||
// This file is part of the "Skylicht Engine" | ||
// Upgrade GPU Compute Shader feature | ||
|
||
#ifndef __C_DIRECTX11_RWBUFFER_H_INCLUDED__ | ||
#define __C_DIRECTX11_RWBUFFER_H_INCLUDED__ | ||
|
||
#include "IrrCompileConfig.h" | ||
|
||
#ifdef _IRR_WINDOWS_ | ||
#ifdef _IRR_COMPILE_WITH_DIRECT3D_11_ | ||
|
||
#include "IRWBuffer.h" | ||
|
||
namespace irr | ||
{ | ||
namespace video | ||
{ | ||
class CD3D11Driver; | ||
|
||
class CD3D11RWBuffer : public IRWBuffer | ||
{ | ||
public: | ||
CD3D11RWBuffer(CD3D11Driver *driver, ECOLOR_FORMAT format, u32 numElements); | ||
|
||
~CD3D11RWBuffer(); | ||
|
||
protected: | ||
|
||
CD3D11Driver *Driver; | ||
|
||
ID3D11Device* Device; | ||
ID3D11DeviceContext* Context; | ||
|
||
ID3D11Buffer* Buffer; | ||
ID3D11ShaderResourceView* SRView; | ||
ID3D11UnorderedAccessView* UAView; | ||
|
||
DXGI_FORMAT D3DFormat; | ||
}; | ||
} | ||
} | ||
|
||
#endif | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
Projects/Skylicht/Lightmapper/Source/Lightmapper/CGPUBaker.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
!@ | ||
MIT License | ||
Copyright (c) 2020 Skylicht Technology CO., LTD | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files | ||
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, | ||
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
This file is part of the "Skylicht Engine". | ||
https://github.com/skylicht-lab/skylicht-engine | ||
!# | ||
*/ | ||
|
||
#include "pch.h" | ||
#include "CGPUBaker.h" | ||
|
||
namespace Skylicht | ||
{ | ||
namespace Lightmapper | ||
{ | ||
CGPUBaker::CGPUBaker() | ||
{ | ||
m_shBuffer = getVideoDriver()->createRWBuffer(video::ECF_A32B32G32R32F, MAX_NUM_THREAD * 9); | ||
} | ||
|
||
CGPUBaker::~CGPUBaker() | ||
{ | ||
if (m_shBuffer != NULL) | ||
m_shBuffer->drop(); | ||
} | ||
|
||
bool CGPUBaker::canUseGPUBaker() | ||
{ | ||
if (getVideoDriver()->getDriverType() == video::EDT_DIRECT3D11 && m_shBuffer != NULL) | ||
return true; | ||
|
||
return false; | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
Projects/Skylicht/Lightmapper/Source/Lightmapper/CGPUBaker.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
!@ | ||
MIT License | ||
Copyright (c) 2020 Skylicht Technology CO., LTD | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files | ||
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, | ||
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
This file is part of the "Skylicht Engine". | ||
https://github.com/skylicht-lab/skylicht-engine | ||
!# | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "CSH9.h" | ||
#include "Camera/CCamera.h" | ||
#include "RenderPipeline/IRenderPipeline.h" | ||
#include "Entity/CEntityManager.h" | ||
|
||
#include "CMTBaker.h" | ||
|
||
namespace Skylicht | ||
{ | ||
namespace Lightmapper | ||
{ | ||
class CGPUBaker : public CMTBaker | ||
{ | ||
protected: | ||
IRWBuffer *m_shBuffer; | ||
|
||
public: | ||
CGPUBaker(); | ||
|
||
virtual ~CGPUBaker(); | ||
|
||
bool canUseGPUBaker(); | ||
}; | ||
} | ||
} |
Oops, something went wrong.