Skip to content

Commit

Permalink
D3D11 Renderer: Fixed SonarCloud issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonJoker committed Jan 13, 2024
1 parent 92bd65f commit 9f7f101
Show file tree
Hide file tree
Showing 125 changed files with 1,641 additions and 1,940 deletions.
4 changes: 2 additions & 2 deletions source/ashes/renderer/D3D11Renderer/Buffer/D3D11Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace ashes::d3d11
{
}

Buffer::~Buffer()
Buffer::~Buffer()noexcept
{
safeRelease( m_unorderedAccessView );
}
Expand Down Expand Up @@ -47,7 +47,7 @@ namespace ashes::d3d11
, D3D11_BOX const & srcBox
, UINT dstOffset )const
{
VkDeviceSize size = srcBox.right - srcBox.left;
VkDeviceSize size = VkDeviceSize( srcBox.right ) - srcBox.left;
get( m_memory )->updateData( get( src )->m_memory
, VkDeviceSize( srcBox.left )
, VkDeviceSize( dstOffset )
Expand Down
23 changes: 12 additions & 11 deletions source/ashes/renderer/D3D11Renderer/Buffer/D3D11Buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
namespace ashes::d3d11
{
class Buffer
: public NonCopyable
{
public:
Buffer( VkDevice device
, VkBufferCreateInfo createInfo );
~Buffer();
~Buffer()noexcept;
VkResult bindMemory( VkDeviceMemory memory
, VkDeviceSize memoryOffset );

Expand All @@ -28,54 +29,54 @@ namespace ashes::d3d11
, D3D11_BOX const & srcBox
, UINT dstOffset )const;

inline void setDebugName( std::string name )
void setDebugName( std::string name )
{
m_debugName = std::move( name );
}

inline VkDeviceMemory getMemory()const
VkDeviceMemory getMemory()const
{
assert( m_memory != nullptr );
return m_memory;
}

inline VkDeviceSize getMemoryOffset()const
VkDeviceSize getMemoryOffset()const
{
return m_memoryOffset;
}

inline ObjectMemory const & getObjectMemory()const
ObjectMemory const & getObjectMemory()const
{
assert( m_objectMemory != nullptr );
return *m_objectMemory;
}

inline ID3D11UnorderedAccessView * getUnorderedAccessView()const
ID3D11UnorderedAccessView * getUnorderedAccessView()const
{
return m_unorderedAccessView;
}

inline ID3D11Resource * getResource()const
ID3D11Resource * getResource()const
{
return getObjectMemory().resource;
}

inline ID3D11Buffer * getBuffer()const
ID3D11Buffer * getBuffer()const
{
return &static_cast< ID3D11Buffer & >( *getResource() );
}

inline VkBufferUsageFlags getUsage()const
VkBufferUsageFlags getUsage()const
{
return m_createInfo.usage;
}

inline VkDeviceSize getSize()const
VkDeviceSize getSize()const
{
return m_createInfo.size;
}

inline VkDevice getDevice()const
VkDevice getDevice()const
{
return m_device;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace ashes::d3d11
}
}

BufferView::~BufferView()
BufferView::~BufferView()noexcept
{
safeRelease( m_view );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@
namespace ashes::d3d11
{
class BufferView
: public NonCopyable
{
public:
BufferView( VkDevice device
, VkBufferViewCreateInfo createInfo );
~BufferView();
~BufferView()noexcept;

inline ID3D11ShaderResourceView * getView()const
ID3D11ShaderResourceView * getView()const
{
return m_view;
}

inline VkDevice getDevice()const
VkDevice getDevice()const
{
return m_device;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ namespace ashes::d3d11
{
BeginQueryCommand::BeginQueryCommand( VkDevice device
, VkQueryPool pool
, uint32_t query
, VkQueryControlFlags flags )
, uint32_t query )
: CommandBase{ device }
, m_query{ *( get( pool )->begin() + query ) }
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ namespace ashes::d3d11
public:
BeginQueryCommand( VkDevice device
, VkQueryPool pool
, uint32_t query
, VkQueryControlFlags flags );
, uint32_t query );

void apply( Context const & context )const override;
CommandPtr clone()const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace ashes::d3d11
{
auto rp = get( renderPass );
assert( clearValues.size() == rp->size() );
for ( auto & attach : *rp )
for ( auto const & attach : *rp )
{
auto & clearValue = clearValues[attach.attachment];

Expand All @@ -45,7 +45,7 @@ namespace ashes::d3d11
auto & views = get( m_frameBuffer )->getAllViews();
uint32_t clearIndex = 0u;

for ( auto & reference : *get( m_renderPass ) )
for ( auto const & reference : *get( m_renderPass ) )
{
auto & attachDesc = get( m_renderPass )->getAttachment( reference );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ namespace ashes::d3d11
CommandPtr clone()const override;

private:
VkRenderPass m_renderPass;
VkFramebuffer m_frameBuffer;
VkClearValueArray m_rtClearValues;
VkClearValue m_dsClearValue;
RECT m_scissor;
VkRenderPass m_renderPass{};
VkFramebuffer m_frameBuffer{};
VkClearValueArray m_rtClearValues{};
VkClearValue m_dsClearValue{};
RECT m_scissor{};
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ namespace ashes::d3d11
auto attaches = makeArrayView( m_subpass.pColorAttachments
, m_subpass.colorAttachmentCount );

for ( auto & attach : attaches )
for ( auto const & attach : attaches )
{
m_attaches.push_back( static_cast< ID3D11RenderTargetView * >( allViews[attach.attachment]->view ) );
m_attaches.emplace_back( static_cast< ID3D11RenderTargetView * >( allViews[attach.attachment]->view ) );
}

if ( m_subpass.pDepthStencilAttachment )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace ashes::d3d11
context->CSSetUnorderedAccessViews( bindingIndex, 1u, &view, nullptr );
}
// Storage buffer/image
static void gather( UINT bindingIndex, ID3D11UnorderedAccessView * view, std::map< UINT, ID3D11UnorderedAccessView * > * uavs )
static void gather( UINT, ID3D11UnorderedAccessView const *, std::map< UINT, ID3D11UnorderedAccessView * > const * )
{
}
};
Expand Down Expand Up @@ -277,7 +277,7 @@ namespace ashes::d3d11
context->CSSetShaderResources( bindingIndex, 1u, &image );
}
// Uniform Buffer
static void bind( ID3D11DeviceContext * context, UINT bindingIndex, ID3D11Buffer * buffer, UINT offset, UINT range )
static void bind( ID3D11DeviceContext * context, UINT bindingIndex, ID3D11Buffer * buffer, UINT offset, UINT )
{
checkOffset( offset );
context->CSSetConstantBuffers( bindingIndex, 1u, &buffer );
Expand All @@ -288,7 +288,7 @@ namespace ashes::d3d11
context->CSSetUnorderedAccessViews( bindingIndex, 1u, &view, nullptr );
}
// Storage buffer/image
static void gather( UINT bindingIndex, ID3D11UnorderedAccessView * view, std::map< UINT, ID3D11UnorderedAccessView * > * uavs )
static void gather( UINT, ID3D11UnorderedAccessView const *, std::map< UINT, ID3D11UnorderedAccessView * > const * )
{
}
};
Expand All @@ -313,7 +313,7 @@ namespace ashes::d3d11
context->VSSetShaderResources( bindingIndex, 1u, &image );
}
// Uniform Buffer
static void bind( ID3D11DeviceContext * context, UINT bindingIndex, ID3D11Buffer * buffer, UINT offset, UINT range )
static void bind( ID3D11DeviceContext * context, UINT bindingIndex, ID3D11Buffer * buffer, UINT offset, UINT )
{
checkOffset( offset );
context->VSSetConstantBuffers( bindingIndex, 1u, &buffer );
Expand Down Expand Up @@ -345,7 +345,7 @@ namespace ashes::d3d11
context->GSSetShaderResources( bindingIndex, 1u, &image );
}
// Uniform Buffer
static void bind( ID3D11DeviceContext * context, UINT bindingIndex, ID3D11Buffer * buffer, UINT offset, UINT range )
static void bind( ID3D11DeviceContext * context, UINT bindingIndex, ID3D11Buffer * buffer, UINT offset, UINT )
{
checkOffset( offset );
context->GSSetConstantBuffers( bindingIndex, 1u, &buffer );
Expand Down Expand Up @@ -377,7 +377,7 @@ namespace ashes::d3d11
context->HSSetShaderResources( bindingIndex, 1u, &image );
}
// Uniform Buffer
static void bind( ID3D11DeviceContext * context, UINT bindingIndex, ID3D11Buffer * buffer, UINT offset, UINT range )
static void bind( ID3D11DeviceContext * context, UINT bindingIndex, ID3D11Buffer * buffer, UINT offset, UINT )
{
checkOffset( offset );
context->HSSetConstantBuffers( bindingIndex, 1u, &buffer );
Expand Down Expand Up @@ -409,7 +409,7 @@ namespace ashes::d3d11
context->DSSetShaderResources( bindingIndex, 1u, &image );
}
// Uniform Buffer
static void bind( ID3D11DeviceContext * context, UINT bindingIndex, ID3D11Buffer * buffer, UINT offset, UINT range )
static void bind( ID3D11DeviceContext * context, UINT bindingIndex, ID3D11Buffer * buffer, UINT offset, UINT )
{
checkOffset( offset );
context->DSSetConstantBuffers( bindingIndex, 1u, &buffer );
Expand Down Expand Up @@ -441,7 +441,7 @@ namespace ashes::d3d11
context->PSSetShaderResources( bindingIndex, 1u, &image );
}
// Uniform Buffer
static void bind( ID3D11DeviceContext * context, UINT bindingIndex, ID3D11Buffer * buffer, UINT offset, UINT range )
static void bind( ID3D11DeviceContext * context, UINT bindingIndex, ID3D11Buffer * buffer, UINT offset, UINT )
{
checkOffset( offset );
context->PSSetConstantBuffers( bindingIndex, 1u, &buffer );
Expand Down Expand Up @@ -613,7 +613,7 @@ namespace ashes::d3d11
, flags
, buffer
, UINT( write.pBufferInfo[i].offset ) / 16
, UINT( ashes::getAlignedSize( range, 256ull ) / 16ull ) );
, UINT( ashes::getAlignedSize( range, 256ULL ) / 16ULL ) );
}
}
}
Expand Down Expand Up @@ -668,7 +668,7 @@ namespace ashes::d3d11
, flags
, buffer
, UINT( ( offset + write.pBufferInfo[i].offset ) / 16 )
, UINT( ashes::getAlignedSize( range, 256ull ) / 16ull ) );
, UINT( ashes::getAlignedSize( range, 256ULL ) / 16ULL ) );
}
}
}
Expand Down Expand Up @@ -753,7 +753,7 @@ namespace ashes::d3d11
, LayoutBindingWrites const & writeBinding
, ShaderBindingMap const & bindings
, uint32_t setIndex
, uint32_t offset )
, uint32_t /*offset*/ )
{
for ( auto & write : writeBinding.writes )
{
Expand Down Expand Up @@ -892,7 +892,7 @@ namespace ashes::d3d11
, ShaderBindingMap const & bindings
, uint32_t setIndex
, std::map< UINT, ID3D11UnorderedAccessView * > & uavs
, uint32_t offset )
, uint32_t /*offset*/ )
{
for ( auto & write : writeBinding.writes )
{
Expand Down Expand Up @@ -921,7 +921,7 @@ namespace ashes::d3d11
{
for ( auto i = 0u; i < offsets.size(); ++i )
{
auto & writeBinding = *writes[i];
auto const & writeBinding = *writes[i];

switch ( writeBinding.binding.descriptorType )
{
Expand Down Expand Up @@ -1062,7 +1062,7 @@ namespace ashes::d3d11
, flags
, ( ID3D11Buffer * )nullptr
, UINT( write.pBufferInfo[i].offset / 16 )
, UINT( ashes::getAlignedSize( range, 256ull ) / 16ull ) );
, UINT( ashes::getAlignedSize( range, 256ULL ) / 16ULL ) );
}
}
}
Expand Down Expand Up @@ -1115,7 +1115,7 @@ namespace ashes::d3d11
, flags
, ( ID3D11Buffer * )nullptr
, UINT( ( offset + write.pBufferInfo[i].offset ) / 16 )
, UINT( ashes::getAlignedSize( range, 256ull ) / 16ull ) );
, UINT( ashes::getAlignedSize( range, 256ULL ) / 16ULL ) );
}
}
}
Expand Down Expand Up @@ -1197,7 +1197,7 @@ namespace ashes::d3d11
, LayoutBindingWrites const & writeBinding
, ShaderBindingMap const & bindings
, uint32_t setIndex
, uint32_t offset )
, uint32_t /*offset*/ )
{
for ( auto & write : writeBinding.writes )
{
Expand Down Expand Up @@ -1423,23 +1423,22 @@ namespace ashes::d3d11
bindAll< false >( context, m_layout, m_descriptorSet, m_dynamicOffsets );
}

auto newUavs = context.uavs;
std::map< UINT, ID3D11UnorderedAccessView * > newUavs = context.uavs;

for ( auto it : m_uavs )
for ( auto const & [id, uav] : m_uavs )
{
newUavs[it.first] = it.second;
newUavs[id] = uav;
}

bool dirtyUavs = context.uavs != newUavs;

if ( dirtyUavs )
if ( bool dirtyUavs = context.uavs != newUavs;
dirtyUavs )
{
context.uavs = std::move( newUavs );
context.rawUavs.clear();

for ( auto & uav : context.uavs )
for ( auto const & [id, uav] : context.uavs )
{
context.rawUavs.push_back( uav.second );
context.rawUavs.push_back( uav );
}

if ( !context.rawUavs.empty() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ namespace ashes::d3d11
}

// Bind program
for ( auto & stage : get( m_pipeline )->getShaderStages() )
for ( auto const & stage : get( m_pipeline )->getShaderStages() )
{
switch ( stage.getStage() )
{
Expand Down Expand Up @@ -332,7 +332,7 @@ namespace ashes::d3d11
SetDepthBoundsCommand::SetDepthBoundsCommand( VkDevice device
, DepthBounds const & depthBounds )
: CommandBase{ device }
, m_physicalDevice{ get( m_device )->getPhysicalDevice() }
, m_physicalDevice{ get( getDevice() )->getPhysicalDevice() }
, m_depthBounds{ depthBounds }
{
}
Expand Down
Loading

0 comments on commit 9f7f101

Please sign in to comment.