commit
This commit is contained in:
@@ -72,17 +72,17 @@ float2 g_vDiffuseUVGainAmount;
|
||||
float2 g_vMaskingUVGainAmount;
|
||||
float2 g_vNoiseUVGainAmount;
|
||||
|
||||
int g_iMaskMoveLerpOption;
|
||||
int g_iDiffuseMoveLerpOption;
|
||||
int g_iNoiseMoveLerpOption;
|
||||
int g_iMaskMoveLerpOption;
|
||||
int g_iDiffuseMoveLerpOption;
|
||||
int g_iNoiseMoveLerpOption;
|
||||
|
||||
//
|
||||
float2 g_vDistortionTime;
|
||||
float2 g_vMaskDistortionUVGainAmount;
|
||||
|
||||
|
||||
int g_iMaskDistortionMoveLerpOption;
|
||||
int g_iDiffuseDistortionMoveLerpOption;
|
||||
int g_iMaskDistortionMoveLerpOption;
|
||||
int g_iDiffuseDistortionMoveLerpOption;
|
||||
//
|
||||
|
||||
float2 g_vUVCutting;
|
||||
@@ -90,12 +90,12 @@ float2 g_vUVMaskCutting;
|
||||
|
||||
float g_fDiffuseAlpha;
|
||||
|
||||
int g_iBlurWeight; // 블러 강도
|
||||
int g_iBlurWeight; // 블러 강도
|
||||
float g_fBlurIntensity; //블러 세기
|
||||
float g_fNoiseDistortionIntensity; // 디스토션 왜곡 세기
|
||||
|
||||
float4 g_vEmissive;
|
||||
float g_fEmissiveStrength;
|
||||
float g_fEmissiveStrength;
|
||||
|
||||
float g_fSoftenExp;
|
||||
float g_fSoftStrength;
|
||||
@@ -137,18 +137,18 @@ bool g_isBlurReverseDissolve;
|
||||
|
||||
float g_fBluringStrength;
|
||||
|
||||
bool g_isBloomDissolve;
|
||||
bool g_isBloomReverseDissolve;
|
||||
bool g_isBloomDissolve;
|
||||
bool g_isBloomReverseDissolve;
|
||||
|
||||
float g_fBloomStrength;
|
||||
int g_iBloomType;
|
||||
float g_fBloomStrength;
|
||||
int g_iBloomType;
|
||||
|
||||
float g_fFar;
|
||||
|
||||
float g_fDissolveDelay;
|
||||
float g_fReverseDissolveDelay;
|
||||
float2 g_vDissolveUVGainAmount;
|
||||
bool g_isDissolveMove;
|
||||
float g_fDissolveDelay;
|
||||
float g_fReverseDissolveDelay;
|
||||
float2 g_vDissolveUVGainAmount;
|
||||
bool g_isDissolveMove;
|
||||
|
||||
float g_fDissolveMaskEdge;
|
||||
float g_fDissolveSoftMask;
|
||||
@@ -263,7 +263,6 @@ struct PS_OUT
|
||||
{
|
||||
float4 vDiffuse : SV_TARGET0;
|
||||
float4 vRevealage : SV_TARGET1;
|
||||
float4 vColorTarget : SV_TARGET2;
|
||||
};
|
||||
|
||||
float4 DrawEffect(PS_IN In)
|
||||
@@ -274,7 +273,7 @@ float4 DrawEffect(PS_IN In)
|
||||
vector vMtrlDissolve;
|
||||
vector vMtrlDistortion;
|
||||
|
||||
float fAnimIndex = g_ParticleValue[In.iGPUIndex].vAniIndex.x;
|
||||
float fAnimIndex = g_ParticleValue[In.iGPUIndex].vAniIndex.x;
|
||||
float2 vDiffuseTime = g_ParticleValue[In.iGPUIndex].vDiffuseUVMoveTime;
|
||||
float2 vMaskingTime = g_ParticleValue[In.iGPUIndex].vMaskingUVMoveTime;
|
||||
float2 vNoiseUVMoveTime = g_ParticleValue[In.iGPUIndex].vNoiseUVMoveTime;
|
||||
@@ -456,7 +455,7 @@ float4 DrawEffect(PS_IN In)
|
||||
|
||||
|
||||
if (g_isDissolve == true)
|
||||
{
|
||||
{
|
||||
float fTimeX = (In.vLifeTime.x - g_fDissolveDelay);
|
||||
float fTimeY = (In.vLifeTime.y - g_fDissolveDelay);
|
||||
float fTimeRatio = 0;
|
||||
@@ -481,14 +480,14 @@ float4 DrawEffect(PS_IN In)
|
||||
{
|
||||
vMtrlDiffuse.a *= In.vLifeTime.x / In.vLifeTime.y;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
float2 vDissolveUV = In.vTexcoord + SelectLerpUV(g_vDissolveUVGainAmount, (vDissolveUVMoveTime.x / vDissolveUVMoveTime.y), 0);
|
||||
|
||||
if (g_isDissolveMove)
|
||||
vMtrlDissolve = g_DissolveTexture.Sample(DefaultSampler, vDissolveUV );
|
||||
vMtrlDissolve = g_DissolveTexture.Sample(DefaultSampler, vDissolveUV);
|
||||
else
|
||||
vMtrlDissolve = g_DissolveTexture.Sample(DefaultSampler, In.vTexcoord);
|
||||
|
||||
@@ -557,12 +556,12 @@ float4 DrawEffect(PS_IN In)
|
||||
return vMtrlDiffuse;
|
||||
}
|
||||
|
||||
float4 EmissiveDraw(PS_IN In , float4 Diffuse)
|
||||
float4 EmissiveDraw(PS_IN In, float4 Diffuse)
|
||||
{
|
||||
float4 vEmissiveMtrl = vector(0.f, 0.f, 0.f, 0.f);
|
||||
float2 CenteredUV = In.vTexcoord - 0.5f;
|
||||
float fEmissive = 0.f;
|
||||
float fEmissiveStrength = g_fEmissiveStrength;
|
||||
float fEmissive = 0.f;
|
||||
float fEmissiveStrength = g_fEmissiveStrength;
|
||||
|
||||
if (g_fEmissiveColorCut >= FLT_EPSILON5)
|
||||
{
|
||||
@@ -655,13 +654,13 @@ PS_OUT PS_MAIN(PS_IN In)
|
||||
|
||||
vMtrlDiffuse.rgb += EmissiveDraw(In, vMtrlDiffuse).rgb;
|
||||
|
||||
Out.vDiffuse = float4(0.f, 0.f, 0.f, 0.f);
|
||||
Out.vDiffuse = vMtrlDiffuse;
|
||||
|
||||
return Out;
|
||||
}
|
||||
|
||||
PS_OUT PS_NON_NORMALMAP(PS_IN In)
|
||||
{
|
||||
{
|
||||
PS_OUT Out;
|
||||
|
||||
vector vMtrlDiffuse;
|
||||
@@ -679,12 +678,10 @@ PS_OUT PS_NON_NORMALMAP(PS_IN In)
|
||||
|
||||
vMtrlDiffuse.rgb += EmissiveDraw(In, vMtrlDiffuse).rgb;
|
||||
|
||||
Out = float4(0.f, 0.f, 0.f, 0.f);
|
||||
Out = BlendedWeight(vMtrlDiffuse, In.vProjPos.w);
|
||||
|
||||
//// 색깔 추가할 처리 (이미시브)
|
||||
|
||||
//Out.vDiffuse // 이미시브 스트랭스
|
||||
Out.vColorTarget = vector(0.f, 0.f, 0.f, 0.f);
|
||||
|
||||
|
||||
return Out;
|
||||
}
|
||||
@@ -753,7 +750,7 @@ PS_BLUR_OUT PS_BLUR_NOEMISSIVE(PS_IN In)
|
||||
|
||||
vector vMtrlDiffuse;
|
||||
|
||||
vMtrlDiffuse= DrawEffect(In);
|
||||
vMtrlDiffuse = DrawEffect(In);
|
||||
|
||||
//// 색깔 추가할 처리 (이미시브)
|
||||
|
||||
@@ -768,7 +765,7 @@ PS_BLUR_OUT PS_BLUR_NOEMISSIVE(PS_IN In)
|
||||
// }
|
||||
//}
|
||||
|
||||
Out.vDiffuse = float4(0.f, 0.f, 0.f, 0.f);
|
||||
Out.vDiffuse = vector(vMtrlDiffuse.rgb * g_fBlurIntensity, vMtrlDiffuse.a);
|
||||
Out.vBlurWeight = g_iBlurWeight / 128.f;
|
||||
|
||||
return Out;
|
||||
@@ -800,7 +797,7 @@ PS_BLUR_OUT PS_BLUR(PS_IN In)
|
||||
// }
|
||||
//}
|
||||
|
||||
Out.vDiffuse = float4(0.f, 0.f, 0.f, 0.f);
|
||||
Out.vDiffuse = vector(vMtrlDiffuse.rgb * g_fBlurIntensity, vMtrlDiffuse.a);
|
||||
|
||||
Out.vBlurWeight = g_iBlurWeight / 128.f;
|
||||
|
||||
@@ -824,7 +821,7 @@ PS_BLOOM_OUT PS_BLOOM(PS_IN In)
|
||||
|
||||
vMtrlDiffuse.rgb += EmissiveDraw(In, vMtrlDiffuse).rgb;
|
||||
|
||||
float fBloomStrength = g_fBloomStrength;
|
||||
float fBloomStrength = g_fBloomStrength;
|
||||
|
||||
if (g_isBloomDissolve == true)
|
||||
{
|
||||
@@ -840,7 +837,7 @@ PS_BLOOM_OUT PS_BLOOM(PS_IN In)
|
||||
if (vMtrlDiffuse.a <= 0.1f)
|
||||
discard;
|
||||
|
||||
Out.vDiffuse = float4(0.f, 0.f, 0.f, 0.f);
|
||||
Out.vDiffuse = vector(vMtrlDiffuse.rgb * fBloomStrength, (float) g_iBloomType / 255.f);
|
||||
|
||||
return Out;
|
||||
|
||||
@@ -856,7 +853,7 @@ PS_BLOOM_OUT PS_BLEND(PS_IN In)
|
||||
|
||||
vMtrlDiffuse.rgb += EmissiveDraw(In, vMtrlDiffuse).rgb;
|
||||
|
||||
Out.vDiffuse = float4(0.f,0.f,0.f,0.f);
|
||||
Out.vDiffuse = vMtrlDiffuse;
|
||||
|
||||
return Out;
|
||||
}
|
||||
@@ -871,7 +868,7 @@ PS_BLOOM_OUT PS_WEIGHTED_FOR_BLEND(PS_IN In)
|
||||
|
||||
vMtrlDiffuse.rgb += EmissiveDraw(In, vMtrlDiffuse).rgb;
|
||||
|
||||
Out.vDiffuse = float4(0.f, 0.f, 0.f, 0.f);
|
||||
Out.vDiffuse = BlendedWeight(vMtrlDiffuse, In.vProjPos.w).vDiffuse;
|
||||
|
||||
|
||||
return Out;
|
||||
|
||||
@@ -4,30 +4,63 @@
|
||||
#include "Instance_Model.h"
|
||||
|
||||
CComputeShader::CComputeShader(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
: m_pDevice{ pDevice }
|
||||
, m_pContext{ pContext }
|
||||
, m_pGameInstance{ CGameInstance::GetInstance() }
|
||||
: CComponent{ pDevice, pContext }
|
||||
{
|
||||
SAFE_ADDREF(m_pDevice);
|
||||
SAFE_ADDREF(m_pContext);
|
||||
SAFE_ADDREF(m_pGameInstance);
|
||||
}
|
||||
|
||||
HRESULT CComputeShader::Initialize(const _tchar* pShaderFilePath, const _char* pStartFunctionName, _uint iNumElement, _uint iNumInputBuffer, _uint iNumOutputBuffer, _uint iInputStructStride[], _uint iOutputStructStride[])
|
||||
CComputeShader::CComputeShader(const CComputeShader& rhs)
|
||||
: CComponent(rhs),
|
||||
m_pCSBlob(rhs.m_pCSBlob)
|
||||
{
|
||||
m_iNumElement = iNumElement;
|
||||
m_iNumInputBuffer = iNumInputBuffer;
|
||||
m_iNumOutputBuffer = iNumOutputBuffer;
|
||||
SAFE_ADDREF(m_pCSBlob);
|
||||
}
|
||||
|
||||
if (FAILED(CreateComputeShader(pShaderFilePath, pStartFunctionName)))
|
||||
HRESULT CComputeShader::Initialize(void* pArg)
|
||||
{
|
||||
|
||||
CS_INFO* CsDesc = static_cast<CS_INFO*>(pArg);
|
||||
|
||||
if (CsDesc == nullptr)
|
||||
return E_FAIL;
|
||||
|
||||
if (FAILED(CreateBuffer(iNumElement, iInputStructStride, iOutputStructStride)))
|
||||
|
||||
m_iNumElement = CsDesc->iNumElement;
|
||||
m_iNumInputBuffer = CsDesc->iNumInputBuffer;
|
||||
m_iNumOutputBuffer = CsDesc->iNumOutputBuffer;
|
||||
|
||||
|
||||
if (FAILED(CreateComputeShader()))
|
||||
return E_FAIL;
|
||||
|
||||
if (FAILED(CreateResurceViews(iNumElement, iNumInputBuffer)))
|
||||
if (FAILED(CreateBuffer(CsDesc->iInputStructStride, CsDesc->iOutputStructStride)))
|
||||
return E_FAIL;
|
||||
|
||||
if (FAILED(CreateResurceViews()))
|
||||
return E_FAIL;
|
||||
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CComputeShader::Initialize_Prototype(const _tchar* pShaderFilePath, const _char* pStartFunctionName)
|
||||
{
|
||||
// Debug 모드와 release 모드의 플레그를 다르게 줘야함
|
||||
UINT HLSLFlags = {};
|
||||
#ifdef _DEBUG
|
||||
HLSLFlags |= D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION;
|
||||
#else
|
||||
HLSLFlags = D3DCOMPILE_OPTIMIZATION_LEVEL1;
|
||||
#endif // _DEBUG
|
||||
|
||||
HRESULT hr = D3DCompileFromFile(pShaderFilePath,
|
||||
nullptr,
|
||||
D3D_COMPILE_STANDARD_FILE_INCLUDE,
|
||||
pStartFunctionName,
|
||||
"cs_5_0",
|
||||
HLSLFlags,
|
||||
0,
|
||||
&m_pCSBlob,
|
||||
nullptr);
|
||||
|
||||
|
||||
return S_OK;
|
||||
@@ -136,7 +169,7 @@ void CComputeShader::Reset()
|
||||
m_pContext->CSSetShader(nullptr, nullptr, 0);
|
||||
}
|
||||
|
||||
HRESULT CComputeShader::CreateBuffer(_uint iNumElement, _uint iInputStructStride[], _uint iOuputStructStride[])
|
||||
HRESULT CComputeShader::CreateBuffer(_uint iInputStructStride[], _uint iOuputStructStride[])
|
||||
{
|
||||
//인 아웃풋 버퍼
|
||||
|
||||
@@ -145,7 +178,7 @@ HRESULT CComputeShader::CreateBuffer(_uint iNumElement, _uint iInputStructStride
|
||||
{
|
||||
D3D11_BUFFER_DESC InputBufferdesc = {};
|
||||
|
||||
InputBufferdesc.ByteWidth = iInputStructStride[i] * iNumElement;
|
||||
InputBufferdesc.ByteWidth = iInputStructStride[i] * m_iNumElement;
|
||||
InputBufferdesc.StructureByteStride = iInputStructStride[i];
|
||||
InputBufferdesc.Usage = D3D11_USAGE_DEFAULT;
|
||||
InputBufferdesc.CPUAccessFlags = 0;
|
||||
@@ -165,7 +198,7 @@ HRESULT CComputeShader::CreateBuffer(_uint iNumElement, _uint iInputStructStride
|
||||
// 아웃풋 버퍼
|
||||
|
||||
D3D11_BUFFER_DESC Bufferdesc = {};
|
||||
Bufferdesc.ByteWidth = iOuputStructStride[i] * iNumElement;
|
||||
Bufferdesc.ByteWidth = iOuputStructStride[i] * m_iNumElement;
|
||||
Bufferdesc.StructureByteStride = iOuputStructStride[i];
|
||||
Bufferdesc.Usage = D3D11_USAGE_DEFAULT; // 인 아웃풋 버퍼는 디폴트로 설정해야함
|
||||
Bufferdesc.CPUAccessFlags = 0; // 디폴트 버퍼는 CPU에서 Read Write가 불가능하며
|
||||
@@ -186,10 +219,10 @@ HRESULT CComputeShader::CreateBuffer(_uint iNumElement, _uint iInputStructStride
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CComputeShader::CreateResurceViews(_uint iNumElement, _uint iNumInputBuffer)
|
||||
HRESULT CComputeShader::CreateResurceViews()
|
||||
{
|
||||
// SRV
|
||||
for (_uint i = 0; i < iNumInputBuffer; i++) // 인풋 버퍼를 여러개 사용할 수 있도록 만든다
|
||||
for (_uint i = 0; i < m_iNumInputBuffer; i++) // 인풋 버퍼를 여러개 사용할 수 있도록 만든다
|
||||
{
|
||||
ID3D11ShaderResourceView* pSrv = {};
|
||||
|
||||
@@ -197,7 +230,7 @@ HRESULT CComputeShader::CreateResurceViews(_uint iNumElement, _uint iNumInputBuf
|
||||
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFEREX;
|
||||
srvDesc.Format = DXGI_FORMAT_UNKNOWN;
|
||||
srvDesc.Buffer.FirstElement = 0;
|
||||
srvDesc.Buffer.NumElements = iNumElement;
|
||||
srvDesc.Buffer.NumElements = m_iNumElement;
|
||||
|
||||
if (FAILED(m_pDevice->CreateShaderResourceView(m_pInputBuffer[i], &srvDesc, &pSrv)))
|
||||
return E_FAIL;
|
||||
@@ -215,7 +248,7 @@ HRESULT CComputeShader::CreateResurceViews(_uint iNumElement, _uint iNumInputBuf
|
||||
uavDesc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
|
||||
uavDesc.Format = DXGI_FORMAT_UNKNOWN;
|
||||
uavDesc.Buffer.FirstElement = 0;
|
||||
uavDesc.Buffer.NumElements = iNumElement;
|
||||
uavDesc.Buffer.NumElements = m_iNumElement;
|
||||
|
||||
ID3D11UnorderedAccessView* pOutputUAV = { nullptr };
|
||||
|
||||
@@ -230,7 +263,7 @@ HRESULT CComputeShader::CreateResurceViews(_uint iNumElement, _uint iNumInputBuf
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
|
||||
srvDesc.Format = DXGI_FORMAT_UNKNOWN; // StructuredBuffer는 UNKNOWN
|
||||
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
|
||||
srvDesc.Buffer.NumElements = iNumElement;
|
||||
srvDesc.Buffer.NumElements = m_iNumElement;
|
||||
srvDesc.Buffer.FirstElement = 0;
|
||||
|
||||
|
||||
@@ -246,48 +279,26 @@ HRESULT CComputeShader::CreateResurceViews(_uint iNumElement, _uint iNumInputBuf
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CComputeShader::CreateComputeShader(const _tchar* pShaderFilePath, const _char* pStartFunctionName)
|
||||
HRESULT CComputeShader::CreateComputeShader()
|
||||
{
|
||||
ID3DBlob* pCSBlob = nullptr;
|
||||
|
||||
// Debug 모드와 release 모드의 플레그를 다르게 줘야함
|
||||
UINT HLSLFlags = {};
|
||||
#ifdef _DEBUG
|
||||
HLSLFlags |= D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION;
|
||||
#else
|
||||
HLSLFlags = D3DCOMPILE_OPTIMIZATION_LEVEL1;
|
||||
#endif // _DEBUG
|
||||
|
||||
HRESULT hr = D3DCompileFromFile(pShaderFilePath,
|
||||
nullptr,
|
||||
D3D_COMPILE_STANDARD_FILE_INCLUDE,
|
||||
pStartFunctionName,
|
||||
"cs_5_0",
|
||||
HLSLFlags,
|
||||
0,
|
||||
&pCSBlob,
|
||||
nullptr);
|
||||
|
||||
|
||||
if (FAILED(m_pDevice->CreateComputeShader(
|
||||
pCSBlob->GetBufferPointer(), // 컴파일된 쉐이더 코드
|
||||
pCSBlob->GetBufferSize(), // 코드 길이
|
||||
m_pCSBlob->GetBufferPointer(), // 컴파일된 쉐이더 코드
|
||||
m_pCSBlob->GetBufferSize(), // 코드 길이
|
||||
nullptr, // 클래스 인스턴스 (없음)
|
||||
&m_pComputeShader // 컴퓨트 쉐이더 객체
|
||||
)))
|
||||
return E_FAIL;
|
||||
|
||||
SAFE_RELEASE(pCSBlob);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
CComputeShader* CComputeShader::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _tchar* pShaderFilePath, const _char* pStartFunctionName, _uint iNumElement, _uint iNumInputBuffer, _uint iNumOutputBuffer, _uint iInputStructStride[], _uint iOutputStructStride[])
|
||||
CComputeShader* CComputeShader::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _tchar* pShaderFilePath, const _char* pStartFunctionName)
|
||||
{
|
||||
CComputeShader* pInstance = new CComputeShader(pDevice, pContext);
|
||||
|
||||
if (FAILED(pInstance->Initialize(pShaderFilePath, pStartFunctionName, iNumElement, iNumInputBuffer, iNumOutputBuffer, iInputStructStride, iOutputStructStride)))
|
||||
if (FAILED(pInstance->Initialize_Prototype(pShaderFilePath, pStartFunctionName)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CComputeShader Prototype");
|
||||
SAFE_RELEASE(pInstance);
|
||||
@@ -318,4 +329,28 @@ void CComputeShader::Free()
|
||||
SAFE_RELEASE(m_pDevice);
|
||||
SAFE_RELEASE(m_pContext);
|
||||
SAFE_RELEASE(m_pGameInstance);
|
||||
|
||||
SAFE_RELEASE(m_pCSBlob);
|
||||
}
|
||||
|
||||
CComponent* CComputeShader::Clone(void* pArg, CGameObject* pOwner)
|
||||
{
|
||||
CComputeShader* pInstance = new CComputeShader(*this);
|
||||
pInstance->m_pOwner = pOwner;
|
||||
|
||||
if (FAILED(pInstance->Initialize(pArg)))
|
||||
{
|
||||
MSG_BOX("Failed to Cloned : CComputeShader");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
void CComputeShader::Describe_Entity()
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -498,11 +498,22 @@ HRESULT CInstance_Model::Create_CS()
|
||||
sizeof(CS_PARTICLE_VALUE_DESC),
|
||||
};
|
||||
|
||||
m_pComputeShader = CComputeShader::Create(m_pDevice, m_pContext,
|
||||
L"../Bin/Resources/ShaderFiles/Shader_Particle_Compute.hlsl", "CS_MAIN", m_iNumInstance, 2, 2, CS_InputStrides, CS_OutputStrides);
|
||||
//, 2, 2, CS_InputStrides, CS_OutputStrides
|
||||
|
||||
if (m_pComputeShader == nullptr)
|
||||
CComputeShader::CS_INFO CS_Desc = {};
|
||||
|
||||
CS_Desc.iNumElement = m_iNumInstance;
|
||||
CS_Desc.iNumInputBuffer = 2;
|
||||
CS_Desc.iNumOutputBuffer = 2;
|
||||
|
||||
CS_Desc.iInputStructStride = CS_InputStrides;
|
||||
CS_Desc.iOutputStructStride = CS_OutputStrides;
|
||||
|
||||
m_pComputeShader = (CComputeShader*)m_pGameInstance->Clone_Asset_Prototype(g_iStaticLevel, CS_EFFECT, &CS_Desc, nullptr);
|
||||
|
||||
if (nullptr == m_pComputeShader) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -98,6 +98,12 @@ HRESULT CPrototype_Manager::Ready_StaticComponents()
|
||||
if (FAILED(Add_Prototype(g_iStaticLevel, CLight::Create(m_pDevice, m_pContext)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
#pragma region Compute Shader
|
||||
|
||||
|
||||
|
||||
#pragma endregion
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -120,6 +126,24 @@ HRESULT CPrototype_Manager::Ready_EngineAssets()
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
#pragma region COMPUTE_SHADER
|
||||
|
||||
if (FAILED(Add_Asset_Prototype(g_iStaticLevel, CS_EFFECT,
|
||||
CComputeShader::Create(m_pDevice, m_pContext,
|
||||
L"../Bin/Resources/ShaderFiles/Shader_Particle_Compute.hlsl", "CS_MAIN")))) {
|
||||
return E_FAIL;
|
||||
|
||||
}
|
||||
|
||||
if (FAILED(Add_Asset_Prototype(g_iStaticLevel, CS_INSTANCE_MODEL,
|
||||
CComputeShader::Create(m_pDevice, m_pContext,
|
||||
L"../Bin/Resources/ShaderFiles/Shader_Instance_Compute.hlsl", "CS_MAIN")))) {
|
||||
return E_FAIL;
|
||||
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -369,11 +369,20 @@ HRESULT CVIBuffer_Model_Instance::Create_ComputeShader()
|
||||
sizeof(VTX_INSTANCE_MODEL),
|
||||
};
|
||||
|
||||
m_pComputeShader = CComputeShader::Create(m_pDevice, m_pContext,
|
||||
L"../Bin/Resources/ShaderFiles/Shader_Instance_Compute.hlsl", "CS_MAIN", m_iMaxNumInstance, 2, 1, CS_InputStrides, CS_OutputStrides);
|
||||
CComputeShader::CS_INFO CS_Desc = {};
|
||||
|
||||
if (m_pComputeShader == nullptr)
|
||||
CS_Desc.iNumElement = m_iMaxNumInstance;
|
||||
CS_Desc.iNumInputBuffer = 2;
|
||||
CS_Desc.iNumOutputBuffer = 1;
|
||||
|
||||
CS_Desc.iInputStructStride = CS_InputStrides;
|
||||
CS_Desc.iOutputStructStride = CS_OutputStrides;
|
||||
|
||||
m_pComputeShader = (CComputeShader*)m_pGameInstance->Clone_Asset_Prototype(g_iStaticLevel, CS_INSTANCE_MODEL, &CS_Desc, nullptr);
|
||||
|
||||
if (nullptr == m_pComputeShader) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "Base.h"
|
||||
#include "Component.h"
|
||||
|
||||
NS_BEGIN(Engine)
|
||||
|
||||
class ENGINE_DLL CComputeShader final : public CBase
|
||||
class ENGINE_DLL CComputeShader final : public CComponent
|
||||
{
|
||||
public:
|
||||
typedef struct tagComputeShaderInfo
|
||||
{
|
||||
_uint iNumElement = {};
|
||||
_uint iNumInputBuffer = {};
|
||||
_uint iNumOutputBuffer = {};
|
||||
_uint* iInputStructStride = { nullptr };
|
||||
_uint* iOutputStructStride = { nullptr };
|
||||
}CS_INFO;
|
||||
private:
|
||||
CComputeShader(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
CComputeShader(const CComputeShader& rhs);
|
||||
virtual ~CComputeShader() = default;
|
||||
|
||||
|
||||
public:
|
||||
HRESULT Initialize(const _tchar* pShaderFilePath, const _char* pStartFunctionName, _uint iNumElement, _uint iNumInputBuffer, _uint iNumOutputBuffer, _uint iInputStructStride[], _uint iOutputStructStride[]);
|
||||
virtual HRESULT Initialize_Prototype(const _tchar* pShaderFilePath, const _char* pStartFunctionName);
|
||||
virtual HRESULT Initialize(void* pArg);
|
||||
public:
|
||||
vector<D3D11_MAPPED_SUBRESOURCE> Dispatch(_uint iSRVIndex, _uint iUAVIndex, _float3 vGroupCount, ID3D11Buffer** ppBuffers, ID3D11Buffer* pConstantBuffer = nullptr);
|
||||
void Bind_OutPut_SRV(_uint iIndex, _uint iBufferIndex);
|
||||
@@ -24,14 +35,9 @@ class ENGINE_DLL CComputeShader final : public CBase
|
||||
void Bind_UAV(_uint iIndex);
|
||||
void Reset();
|
||||
|
||||
HRESULT CreateBuffer(_uint iNumElement, _uint iInputStructStride[], _uint iOuputStructStride[]);
|
||||
HRESULT CreateResurceViews(_uint iNumElement, _uint iNumInputBuffer);
|
||||
HRESULT CreateComputeShader(const _tchar* pShaderFilePath, const _char* pStartFunctionName);
|
||||
|
||||
private:
|
||||
ID3D11Device* m_pDevice = { nullptr };
|
||||
ID3D11DeviceContext* m_pContext = { nullptr };
|
||||
class CGameInstance* m_pGameInstance = { nullptr };
|
||||
HRESULT CreateBuffer(_uint iInputStructStride[], _uint iOuputStructStride[]);
|
||||
HRESULT CreateResurceViews();
|
||||
HRESULT CreateComputeShader();
|
||||
|
||||
private:
|
||||
vector<ID3D11ShaderResourceView*> m_pInputSRV = {};
|
||||
@@ -42,9 +48,9 @@ class ENGINE_DLL CComputeShader final : public CBase
|
||||
vector<ID3D11Buffer*> m_pOutputBuffer = {};
|
||||
|
||||
|
||||
ID3D11ComputeShader* m_pComputeShader = nullptr;
|
||||
|
||||
ID3D11ComputeShader* m_pComputeShader = nullptr;
|
||||
|
||||
ID3DBlob* m_pCSBlob = nullptr;
|
||||
|
||||
private:
|
||||
_uint m_iNumElement = 0; // 인수 개수
|
||||
@@ -52,8 +58,13 @@ class ENGINE_DLL CComputeShader final : public CBase
|
||||
_uint m_iNumOutputBuffer = 0; // 인풋 버퍼의 개수
|
||||
|
||||
public:
|
||||
static CComputeShader* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _tchar* pShaderFilePath, const _char* pStartFunctionName, _uint iNumElement, _uint iNumInputBuffer, _uint iNumOutputBuffer, _uint iInputStructStride[], _uint iOutputStructStride[]);
|
||||
static CComputeShader* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _tchar* pShaderFilePath, const _char* pStartFunctionName);
|
||||
virtual void Free() override;
|
||||
CComponent* Clone(void* pArg, CGameObject* pOwner) override;
|
||||
|
||||
#ifdef _DEBUG
|
||||
void Describe_Entity() override;
|
||||
#endif // _DEBUG
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -75,6 +75,8 @@
|
||||
#define FX_LASTCOLOR TEXT("FX_LASTCOLOR")
|
||||
#define FX_WEIGHTBELND TEXT("FX_WEIGHTBELND")
|
||||
|
||||
#define CS_EFFECT TEXT("CS_EFFECT")
|
||||
#define CS_INSTANCE_MODEL TEXT("CS_INSTANCE_MODEL")
|
||||
|
||||
#define SAFE_ADDREF(pInstance) Safe_AddRef(pInstance)
|
||||
#define SAFE_RELEASE(pInstance) Safe_Release(pInstance)
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "Trail.h"
|
||||
#include "OcclusionQuery.h"
|
||||
#include "Font.h"
|
||||
#include "ComputeShader.h"
|
||||
|
||||
NS_BEGIN(Engine)
|
||||
class CGameInstance;
|
||||
|
||||
Reference in New Issue
Block a user