D3D12: Add bounds check to GetBackBuffer and update unit tests
- Add assert() bounds check to GetBackBuffer() to catch invalid indices - Include <cassert> in D3D12SwapChain.cpp - Update test_swap_chain.cpp to use reference return type - Mark InvalidIndex test as DISABLED (assert aborts on invalid index) - Update get-back-buffer.md documentation
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "XCEngine/RHI/D3D12/D3D12SwapChain.h"
|
||||
#include <cassert>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
@@ -82,10 +83,12 @@ uint32_t D3D12SwapChain::GetCurrentBackBufferIndex() const {
|
||||
}
|
||||
|
||||
D3D12Texture& D3D12SwapChain::GetBackBuffer(uint32_t index) {
|
||||
assert(index < m_backBuffers.size() && "BackBuffer index out of range");
|
||||
return m_backBuffers[index];
|
||||
}
|
||||
|
||||
const D3D12Texture& D3D12SwapChain::GetBackBuffer(uint32_t index) const {
|
||||
assert(index < m_backBuffers.size() && "BackBuffer index out of range");
|
||||
return m_backBuffers[index];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user