Skip to content

Commit

Permalink
Removed old Apply and ApplyAsUnorderedAccessView for StructuredBuffer.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewRichards-Code committed Sep 10, 2024
1 parent 86ddef4 commit 35f0a99
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 64 deletions.
10 changes: 0 additions & 10 deletions CrossPlatform/PlatformStructuredBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,4 @@ void PlatformStructuredBuffer::Apply(crossplatform::DeviceContext& deviceContext
#endif
if (shaderResource.slot >= 0)
deviceContext.contextState.applyStructuredBuffers[shaderResource.slot] = this;
}

void PlatformStructuredBuffer::ApplyAsUnorderedAccessView(crossplatform::DeviceContext& deviceContext, crossplatform::Effect* effect, const ShaderResource& shaderResource)
{
ApplyAsUnorderedAccessView(deviceContext,shaderResource);
}

void PlatformStructuredBuffer::Apply(crossplatform::DeviceContext& deviceContext, crossplatform::Effect* effect, const ShaderResource& shaderResource)
{
Apply(deviceContext,shaderResource);
}
10 changes: 3 additions & 7 deletions CrossPlatform/PlatformStructuredBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ namespace platform
virtual void InvalidateDeviceObjects() = 0;
virtual void Apply(DeviceContext& deviceContext, const ShaderResource& shaderResource);
virtual void ApplyAsUnorderedAccessView(DeviceContext& deviceContext, const ShaderResource& shaderResource);
// Deprecated
virtual void Apply(DeviceContext& deviceContext, Effect* effect, const ShaderResource& shaderResource);
// Deprecated
virtual void ApplyAsUnorderedAccessView(DeviceContext& deviceContext, Effect* effect, const ShaderResource& shaderResource);
virtual void Unbind(DeviceContext& deviceContext) = 0;
virtual void* GetBuffer(crossplatform::DeviceContext& deviceContext) = 0;
virtual const void* OpenReadBuffer(crossplatform::DeviceContext& deviceContext) = 0;
Expand Down Expand Up @@ -158,16 +154,16 @@ namespace platform
}
return platformStructuredBuffer->AsD3D11UnorderedAccessView();
}
void Apply(crossplatform::DeviceContext& pContext, crossplatform::Effect* , const crossplatform::ShaderResource& shaderResource)
void Apply(crossplatform::DeviceContext& pContext, const crossplatform::ShaderResource& shaderResource)
{
if (!platformStructuredBuffer)
{
SIMUL_BREAK_ONCE("Null Platform structured buffer pointer.");
return;
}
platformStructuredBuffer->Apply(pContext, shaderResource);
platformStructuredBuffer->Apply(pContext, shaderResource);
}
void ApplyAsUnorderedAccessView(crossplatform::DeviceContext& pContext, crossplatform::Effect* , const crossplatform::ShaderResource& shaderResource)
void ApplyAsUnorderedAccessView(crossplatform::DeviceContext& pContext, const crossplatform::ShaderResource& shaderResource)
{
if (!platformStructuredBuffer)
{
Expand Down
2 changes: 1 addition & 1 deletion CrossPlatform/RenderPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ vec4 RenderPlatform::TexelQuery(DeviceContext &deviceContext,int query_id,uint2
}
debugConstants.queryPos=pos;
SetConstantBuffer(deviceContext,&debugConstants);
textureQueryResult.ApplyAsUnorderedAccessView(deviceContext,debugEffect,debugEffect->GetShaderResource("textureQueryResults"));
textureQueryResult.ApplyAsUnorderedAccessView(deviceContext,debugEffect->GetShaderResource("textureQueryResults"));
debugEffect->SetTexture(deviceContext,"imageTexture",texture);
debugEffect->Apply(deviceContext,"texel_query",0);
DispatchCompute(deviceContext,textureQueryResult.count,1,1);
Expand Down
5 changes: 5 additions & 0 deletions CrossPlatform/RenderPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,11 @@ namespace platform
/// <param name="deviceContext"></param>
/// <param name="s"></param>
virtual void SetStructuredBuffer (DeviceContext& deviceContext, BaseStructuredBuffer* s, const ShaderResource& shaderResource);
template<typename T>
void SetStructuredBuffer (DeviceContext& deviceContext, StructuredBuffer<T>& s, const ShaderResource& shaderResource)
{
SetStructuredBuffer(deviceContext, &s, shaderResource);
}
///
virtual void SetAccelerationStructure (DeviceContext& deviceContext, const ShaderResource& res, TopLevelAccelerationStructure* a);

Expand Down
10 changes: 5 additions & 5 deletions CrossPlatform/SphericalHarmonics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ bool SphericalHarmonics::Probe(crossplatform::DeviceContext &deviceContext
{
probeResultsRW.RestoreDeviceObjects(renderPlatform,size.x*size.y*2,true,false,nullptr,"probeResultsRW");
}
probeResultsRW.ApplyAsUnorderedAccessView(deviceContext, sphericalHarmonicsEffect,sphericalHarmonicsEffect->GetShaderResource("targetBuffer"));
probeResultsRW.ApplyAsUnorderedAccessView(deviceContext,sphericalHarmonicsEffect->GetShaderResource("targetBuffer"));

sphericalHarmonicsConstants.lookupOffset=uint3(pos.x,pos.y,face_index);
sphericalHarmonicsConstants.lookupSize=size;
Expand Down Expand Up @@ -219,7 +219,7 @@ void SphericalHarmonics::CalcSphericalHarmonics(crossplatform::DeviceContext &de
{
// The table of 3D directional sample positions. sqrt_jitter_samples x sqrt_jitter_samples
// We just fill this buffer_texture with random 3d directions.
sphericalSamples.ApplyAsUnorderedAccessView(deviceContext, sphericalHarmonicsEffect, _samplesBufferRW);
sphericalSamples.ApplyAsUnorderedAccessView(deviceContext, _samplesBufferRW);
renderPlatform->SetTexture(deviceContext,_cubemapTexture ,buffer_texture);
renderPlatform->SetConstantBuffer(deviceContext, &sphericalHarmonicsConstants);
sphericalHarmonicsEffect->Apply(deviceContext,jitter,0);
Expand Down Expand Up @@ -256,8 +256,8 @@ void SphericalHarmonics::CalcSphericalHarmonics(crossplatform::DeviceContext &de
SIMUL_COMBINED_PROFILE_START(deviceContext,"encode")
{
renderPlatform->SetTexture(deviceContext, _cubemapTexture, buffer_texture);
sphericalSamples.Apply(deviceContext, sphericalHarmonicsEffect, _samplesBuffer);
sphericalHarmonics.ApplyAsUnorderedAccessView(deviceContext,sphericalHarmonicsEffect,_targetBuffer);
sphericalSamples.Apply(deviceContext, _samplesBuffer);
sphericalHarmonics.ApplyAsUnorderedAccessView(deviceContext,_targetBuffer);

static bool sh_by_samples=false;
renderPlatform->SetConstantBuffer(deviceContext, &sphericalHarmonicsConstants);
Expand Down Expand Up @@ -326,7 +326,7 @@ void SphericalHarmonics::RenderEnvmap(GraphicsDeviceContext &deviceContext,cross
lightProbeConstants.alpha = 1.0f-blend;

renderPlatform->SetConstantBuffer(deviceContext, &lightProbeConstants);
GetSphericalHarmonics().Apply(deviceContext, lightProbesEffect, _basisBuffer);
GetSphericalHarmonics().Apply(deviceContext, _basisBuffer);
lightProbesEffect->Apply(deviceContext, tech, 0);
if(blend>0.0f)
renderPlatform->SetStandardRenderState(deviceContext, crossplatform::StandardRenderState::STANDARD_ALPHA_BLENDING);
Expand Down
4 changes: 2 additions & 2 deletions CrossPlatform/Text3DRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ int Text3DRenderer::Render(GraphicsDeviceContext &deviceContext,float x0,float y
effect->Apply(deviceContext,textTech,passIndex);
renderPlatform->SetConstantBuffer(deviceContext, &constantBuffer);
renderPlatform->SetVertexBuffers(deviceContext,0,0,nullptr,nullptr);
f.Apply(deviceContext,effect,_fontChars);
f.Apply(deviceContext,_fontChars);
renderPlatform->SetTopology(deviceContext, Topology::TRIANGLELIST);
renderPlatform->Draw(deviceContext,6*n,0);
effect->UnbindTextures(deviceContext);
Expand Down Expand Up @@ -482,7 +482,7 @@ int Text3DRenderer::Render(MultiviewGraphicsDeviceContext& deviceContext, float*
effect->Apply(deviceContext, textTech, passIndex);
renderPlatform->SetConstantBuffer(deviceContext, &constantBuffer);
renderPlatform->SetVertexBuffers(deviceContext, 0, 0, nullptr, nullptr);
f.Apply(deviceContext, effect, _fontChars);
f.Apply(deviceContext, _fontChars);
renderPlatform->SetTopology(deviceContext, Topology::TRIANGLELIST);
renderPlatform->Draw(deviceContext, 6 * n, 0);
effect->UnbindTextures(deviceContext);
Expand Down
4 changes: 2 additions & 2 deletions CrossPlatform/TextRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ int TextRenderer::Render(GraphicsDeviceContext &deviceContext,float x0,float y,f
renderPlatform->SetConstantBuffer(deviceContext, &constantBuffer);
renderPlatform->SetVertexBuffers(deviceContext,0,0,nullptr,nullptr);
renderPlatform->SetTopology(deviceContext, Topology::TRIANGLELIST);
f.Apply(deviceContext,effect,_fontChars);
f.Apply(deviceContext,_fontChars);
renderPlatform->Draw(deviceContext,6*n,0);
effect->UnbindTextures(deviceContext);
effect->Unapply(deviceContext);
Expand Down Expand Up @@ -431,7 +431,7 @@ int TextRenderer::Render(MultiviewGraphicsDeviceContext& deviceContext, float* x
effect->Apply(deviceContext, textTech, passIndex);
renderPlatform->SetConstantBuffer(deviceContext, &constantBuffer);
renderPlatform->SetVertexBuffers(deviceContext, 0, 0, nullptr, nullptr);
f.Apply(deviceContext, effect, _fontChars);
f.Apply(deviceContext, _fontChars);
renderPlatform->Draw(deviceContext, 6 * n, 0);
effect->UnbindTextures(deviceContext);
effect->Unapply(deviceContext);
Expand Down
4 changes: 2 additions & 2 deletions DirectX12/PlatformStructuredBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void PlatformStructuredBuffer::RestoreDeviceObjects(crossplatform::RenderPlatfor

void PlatformStructuredBuffer::Apply(crossplatform::DeviceContext& deviceContext, const crossplatform::ShaderResource &shaderResource)
{
crossplatform::PlatformStructuredBuffer::Apply(deviceContext, shaderResource);
crossplatform::PlatformStructuredBuffer::Apply(deviceContext, shaderResource);

// Reset the current applies, we need to do this even if we didnt change the buffer:
if (mLastFrame != renderPlatform->GetFrameNumber())
Expand All @@ -206,7 +206,7 @@ void PlatformStructuredBuffer::Apply(crossplatform::DeviceContext& deviceContext

void PlatformStructuredBuffer::ApplyAsUnorderedAccessView(crossplatform::DeviceContext& deviceContext, const crossplatform::ShaderResource &shaderResource)
{
crossplatform::PlatformStructuredBuffer::ApplyAsUnorderedAccessView(deviceContext, shaderResource);
crossplatform::PlatformStructuredBuffer::ApplyAsUnorderedAccessView(deviceContext, shaderResource);

// Reset the current applies, we need to do this even if we didnt change the buffer:
if (mLastFrame != renderPlatform->GetFrameNumber())
Expand Down
14 changes: 2 additions & 12 deletions GLES/Effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,17 +342,7 @@ void PlatformStructuredBuffer::SetData(crossplatform::DeviceContext& deviceConte

void PlatformStructuredBuffer::Apply(crossplatform::DeviceContext& deviceContext, const crossplatform::ShaderResource& shaderResource)
{
Apply(deviceContext, nullptr, shaderResource);
}

void PlatformStructuredBuffer::ApplyAsUnorderedAccessView(crossplatform::DeviceContext& deviceContext, const crossplatform::ShaderResource& shaderResource)
{
ApplyAsUnorderedAccessView(deviceContext, nullptr, shaderResource);
}

void PlatformStructuredBuffer::Apply(crossplatform::DeviceContext& deviceContext,crossplatform::Effect* effect,const crossplatform::ShaderResource &shaderResource)
{
// mLastIdx is the one we last used to write to.
// mLastIdx is the one we last used to write to.
int idx = mLastIdx;
if (mBinding != shaderResource.slot)
{
Expand All @@ -370,7 +360,7 @@ void PlatformStructuredBuffer::Apply(crossplatform::DeviceContext& deviceContext
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, mBinding, mGPUBuffer[idx]);
}

void PlatformStructuredBuffer::ApplyAsUnorderedAccessView(crossplatform::DeviceContext& deviceContext,crossplatform::Effect* effect,const crossplatform::ShaderResource &shaderResource)
void PlatformStructuredBuffer::ApplyAsUnorderedAccessView(crossplatform::DeviceContext& deviceContext, const crossplatform::ShaderResource& shaderResource)
{
mLastIdx = GetIndex(deviceContext);
Apply(deviceContext,effect,shaderResource);
Expand Down
5 changes: 0 additions & 5 deletions GLES/Effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ namespace simul
void Apply(crossplatform::DeviceContext& deviceContext, const crossplatform::ShaderResource& shaderResource);
void ApplyAsUnorderedAccessView(crossplatform::DeviceContext& deviceContext, const crossplatform::ShaderResource& shaderResource);

// Deprecated
void Apply(crossplatform::DeviceContext& deviceContext, crossplatform::Effect* effect, const crossplatform::ShaderResource& shaderResource);
// Deprecated
void ApplyAsUnorderedAccessView(crossplatform::DeviceContext& deviceContext, crossplatform::Effect* effect, const crossplatform::ShaderResource& shaderResource);

void AddFence(crossplatform::DeviceContext& deviceContext);

void Unbind(crossplatform::DeviceContext& deviceContext);
Expand Down
16 changes: 3 additions & 13 deletions OpenGL/Effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,7 @@ void PlatformStructuredBuffer::SetData(crossplatform::DeviceContext& deviceConte

void PlatformStructuredBuffer::Apply(crossplatform::DeviceContext& deviceContext, const crossplatform::ShaderResource& shaderResource)
{
Apply(deviceContext, nullptr, shaderResource);
}

void PlatformStructuredBuffer::ApplyAsUnorderedAccessView(crossplatform::DeviceContext& deviceContext, const crossplatform::ShaderResource& shaderResource)
{
ApplyAsUnorderedAccessView(deviceContext, nullptr, shaderResource);
}

void PlatformStructuredBuffer::Apply(crossplatform::DeviceContext& deviceContext,crossplatform::Effect* effect,const crossplatform::ShaderResource &shaderResource)
{
// mLastIdx is the one we last used to write to.
// mLastIdx is the one we last used to write to.
int idx = mLastIdx;
if (mBinding != shaderResource.slot)
{
Expand All @@ -336,10 +326,10 @@ void PlatformStructuredBuffer::Apply(crossplatform::DeviceContext& deviceContext
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, mBinding, mGPUBuffer[idx]);
}

void PlatformStructuredBuffer::ApplyAsUnorderedAccessView(crossplatform::DeviceContext& deviceContext,crossplatform::Effect* effect,const crossplatform::ShaderResource &shaderResource)
void PlatformStructuredBuffer::ApplyAsUnorderedAccessView(crossplatform::DeviceContext& deviceContext, const crossplatform::ShaderResource& shaderResource)
{
mLastIdx = GetIndex(deviceContext);
Apply(deviceContext,effect,shaderResource);
Apply(deviceContext,shaderResource);
}

void PlatformStructuredBuffer::AddFence(crossplatform::DeviceContext& deviceContext)
Expand Down
5 changes: 0 additions & 5 deletions OpenGL/Effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ namespace platform
void Apply(crossplatform::DeviceContext& deviceContext, const crossplatform::ShaderResource& shaderResource);
void ApplyAsUnorderedAccessView(crossplatform::DeviceContext& deviceContext, const crossplatform::ShaderResource& shaderResource);

// Deprecated
void Apply(crossplatform::DeviceContext& deviceContext, crossplatform::Effect* effect, const crossplatform::ShaderResource& shaderResource);
// Deprecated
void ApplyAsUnorderedAccessView(crossplatform::DeviceContext& deviceContext, crossplatform::Effect* effect, const crossplatform::ShaderResource& shaderResource);

void AddFence(crossplatform::DeviceContext& deviceContext);

void Unbind(crossplatform::DeviceContext& deviceContext);
Expand Down

0 comments on commit 35f0a99

Please sign in to comment.