Skip to content

Commit 985b343

Browse files
add span versions of setScissor and setViewport, and deprecate non-span versions
Also nice defaults for Framebuffer creation params
1 parent 43d74d6 commit 985b343

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

include/nbl/asset/IFramebuffer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ class IFramebuffer
1919
using attachment_ptr_t = std::conditional_t<Creation,ImageViewType*const *,core::smart_refctd_ptr<ImageViewType>*>;
2020

2121
core::smart_refctd_ptr<renderpass_t> renderpass;
22-
attachment_ptr_t depthStencilAttachments;
23-
attachment_ptr_t colorAttachments;
22+
attachment_ptr_t depthStencilAttachments = nullptr;
23+
attachment_ptr_t colorAttachments = nullptr;
2424
uint32_t width;
2525
uint32_t height;
26-
uint32_t layers;
26+
uint32_t layers = 1;
2727
};
2828
struct SCreationParams : SCreationParamsBase<true>
2929
{

include/nbl/video/IGPUCommandBuffer.h

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -301,30 +301,39 @@ class NBL_API2 IGPUCommandBuffer : public IBackendObject
301301
bool bindIndexBuffer(const asset::SBufferBinding<const IGPUBuffer>& binding, const asset::E_INDEX_TYPE indexType);
302302

303303
//! dynamic state
304-
inline bool setScissor(const uint32_t first, const uint32_t count, const VkRect2D* const pScissors)
304+
inline bool setScissor(const uint32_t first, const std::span<const VkRect2D> scissors)
305305
{
306+
const uint32_t count = scissors.size();
306307
if(invalidDynamic(first,count))
307308
return false;
308309

309-
for (auto i=0u; i<count; i++)
310+
for (const auto& scissor : scissors)
310311
{
311-
const auto& scissor = pScissors[i];
312312
if (scissor.offset.x<0 || scissor.offset.y<0)
313313
return false;
314-
if (pScissors[i].extent.width>std::numeric_limits<int32_t>::max()-scissor.offset.x)
314+
if (scissor.extent.width>std::numeric_limits<int32_t>::max()-scissor.offset.x)
315315
return false;
316-
if (pScissors[i].extent.height>std::numeric_limits<int32_t>::max()-scissor.offset.y)
316+
if (scissor.extent.height>std::numeric_limits<int32_t>::max()-scissor.offset.y)
317317
return false;
318318
}
319319

320-
return setScissor_impl(first,count,pScissors);
320+
return setScissor_impl(first,count,scissors.data());
321321
}
322-
inline bool setViewport(const uint32_t first, const uint32_t count, const asset::SViewport* const pViewports)
322+
[[deprecated]] inline bool setScissor(const uint32_t first, const uint32_t count, const VkRect2D* const pScissors)
323323
{
324+
return setScissor(first,{pScissors,count});
325+
}
326+
inline bool setViewport(const uint32_t first, const std::span<const asset::SViewport> viewports)
327+
{
328+
const uint32_t count = viewports.size();
324329
if (invalidDynamic(first,count))
325330
return false;
326331

327-
return setViewport_impl(first,count,pViewports);
332+
return setViewport_impl(first,count,viewports.data());
333+
}
334+
[[deprecated]] inline bool setViewport(const uint32_t first, const uint32_t count, const asset::SViewport* const pViewports)
335+
{
336+
return setViewport(first,{pViewports,count});
328337
}
329338
bool setLineWidth(const float width);
330339
inline bool setDepthBias(const float depthBiasConstantFactor, const float depthBiasClamp, const float depthBiasSlopeFactor)

0 commit comments

Comments
 (0)