Skip to content

Commit

Permalink
MVKCmdRenderPass: Removed MVKCmdBeginRenderPassBase.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Sikorski committed Oct 6, 2022
1 parent 4042693 commit f9674d3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 71 deletions.
36 changes: 9 additions & 27 deletions MoltenVK/MoltenVK/Commands/MVKCmdRenderPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,13 @@ class MVKRenderPass;
class MVKFramebuffer;


#pragma mark -
#pragma mark MVKCmdBeginRenderPassBase

/**
* Abstract base class of MVKCmdBeginRenderPass.
* Contains all pieces that are independent of the templated portions.
*/
class MVKCmdBeginRenderPassBase : public MVKCommand {

public:
VkResult setContent(MVKCommandBuffer* cmdBuff,
const VkRenderPassBeginInfo* pRenderPassBegin,
const VkSubpassBeginInfo* pSubpassBeginInfo);

inline MVKRenderPass* getRenderPass() { return _renderPass; }

protected:

MVKCommandVector<MVKCommandVector<MTLSamplePosition>> _subpassSamplePositions;
MVKRenderPass* _renderPass;
MVKFramebuffer* _framebuffer;
VkRect2D _renderArea;
VkSubpassContents _contents;
};


#pragma mark -
#pragma mark MVKCmdBeginRenderPass

/**
* Vulkan command to begin a render pass.
*/
class MVKCmdBeginRenderPass : public MVKCmdBeginRenderPassBase {
class MVKCmdBeginRenderPass : public MVKCommand {

public:
VkResult setContent(MVKCommandBuffer* cmdBuff,
Expand All @@ -70,7 +44,15 @@ class MVKCmdBeginRenderPass : public MVKCmdBeginRenderPassBase {

void encode(MVKCommandEncoder* cmdEncoder) override;

inline MVKRenderPass* getRenderPass() { return _renderPass; }

protected:
MVKCommandVector<MVKCommandVector<MTLSamplePosition>> _subpassSamplePositions;
MVKRenderPass* _renderPass;
MVKFramebuffer* _framebuffer;
VkRect2D _renderArea;
VkSubpassContents _contents;

MVKCommandVector<VkClearValue> _clearValues;
MVKCommandVector<MVKImageView*> _attachments;
};
Expand Down
70 changes: 29 additions & 41 deletions MoltenVK/MoltenVK/Commands/MVKCmdRenderPass.mm
Original file line number Diff line number Diff line change
Expand Up @@ -26,54 +26,42 @@
#include "mvk_datatypes.hpp"


#pragma mark -
#pragma mark MVKCmdBeginRenderPassBase

VkResult MVKCmdBeginRenderPassBase::setContent(MVKCommandBuffer* cmdBuff,
const VkRenderPassBeginInfo* pRenderPassBegin,
const VkSubpassBeginInfo* pSubpassBeginInfo) {
_contents = pSubpassBeginInfo->contents;
_renderPass = (MVKRenderPass*)pRenderPassBegin->renderPass;
_framebuffer = (MVKFramebuffer*)pRenderPassBegin->framebuffer;
_renderArea = pRenderPassBegin->renderArea;
_subpassSamplePositions.alc.cmdBuffer = cmdBuff;

for (const auto* next = (VkBaseInStructure*)pRenderPassBegin->pNext; next; next = next->pNext) {
switch (next->sType) {
case VK_STRUCTURE_TYPE_RENDER_PASS_SAMPLE_LOCATIONS_BEGIN_INFO_EXT: {
// Build an array of arrays, one array of sample positions for each subpass index.
// For subpasses not included in VkRenderPassSampleLocationsBeginInfoEXT, the resulting array of samples will be empty.
_subpassSamplePositions.resize(_renderPass->getSubpassCount());
auto* pRPSampLocnsInfo = (VkRenderPassSampleLocationsBeginInfoEXT*)next;
for (uint32_t spSLIdx = 0; spSLIdx < pRPSampLocnsInfo->postSubpassSampleLocationsCount; spSLIdx++) {
auto& spsl = pRPSampLocnsInfo->pPostSubpassSampleLocations[spSLIdx];
uint32_t spIdx = spsl.subpassIndex;
auto& spSampPosns = _subpassSamplePositions[spIdx];
spSampPosns.alc.cmdBuffer = cmdBuff;
for (uint32_t slIdx = 0; slIdx < spsl.sampleLocationsInfo.sampleLocationsCount; slIdx++) {
auto& sl = spsl.sampleLocationsInfo.pSampleLocations[slIdx];
spSampPosns.push_back(MTLSamplePositionMake(sl.x, sl.y));
}
}
break;
}
default:
break;
}
}

return VK_SUCCESS;
}


#pragma mark -
#pragma mark MVKCmdBeginRenderPass

VkResult MVKCmdBeginRenderPass::setContent(MVKCommandBuffer* cmdBuff,
const VkRenderPassBeginInfo* pRenderPassBegin,
const VkSubpassBeginInfo* pSubpassBeginInfo,
MVKArrayRef<MVKImageView*> attachments) {
MVKCmdBeginRenderPassBase::setContent(cmdBuff, pRenderPassBegin, pSubpassBeginInfo);
_contents = pSubpassBeginInfo->contents;
_renderPass = (MVKRenderPass*)pRenderPassBegin->renderPass;
_framebuffer = (MVKFramebuffer*)pRenderPassBegin->framebuffer;
_renderArea = pRenderPassBegin->renderArea;
_subpassSamplePositions.alc.cmdBuffer = cmdBuff;

for (const auto* next = (VkBaseInStructure*)pRenderPassBegin->pNext; next; next = next->pNext) {
switch (next->sType) {
case VK_STRUCTURE_TYPE_RENDER_PASS_SAMPLE_LOCATIONS_BEGIN_INFO_EXT: {
// Build an array of arrays, one array of sample positions for each subpass index.
// For subpasses not included in VkRenderPassSampleLocationsBeginInfoEXT, the resulting array of samples will be empty.
_subpassSamplePositions.resize(_renderPass->getSubpassCount());
auto* pRPSampLocnsInfo = (VkRenderPassSampleLocationsBeginInfoEXT*)next;
for (uint32_t spSLIdx = 0; spSLIdx < pRPSampLocnsInfo->postSubpassSampleLocationsCount; spSLIdx++) {
auto& spsl = pRPSampLocnsInfo->pPostSubpassSampleLocations[spSLIdx];
uint32_t spIdx = spsl.subpassIndex;
auto& spSampPosns = _subpassSamplePositions[spIdx];
spSampPosns.alc.cmdBuffer = cmdBuff;
for (uint32_t slIdx = 0; slIdx < spsl.sampleLocationsInfo.sampleLocationsCount; slIdx++) {
auto& sl = spsl.sampleLocationsInfo.pSampleLocations[slIdx];
spSampPosns.push_back(MTLSamplePositionMake(sl.x, sl.y));
}
}
break;
}
default:
break;
}
}

_attachments.alc.cmdBuffer = cmdBuff;
_attachments.assign(attachments.begin(), attachments.end());
Expand Down
4 changes: 2 additions & 2 deletions MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MVKCommandPool;
class MVKQueueCommandBufferSubmission;
class MVKCommandEncoder;
class MVKCommandEncodingPool;
class MVKCmdBeginRenderPassBase;
class MVKCmdBeginRenderPass;
class MVKCmdNextSubpass;
class MVKRenderPass;
class MVKFramebuffer;
Expand Down Expand Up @@ -134,7 +134,7 @@ class MVKCommandBuffer : public MVKDispatchableVulkanAPIObject,
#pragma mark Multiview render pass command management

/** Update the last recorded multiview render pass */
void recordBeginRenderPass(MVKCmdBeginRenderPassBase* mvkBeginRenderPass);
void recordBeginRenderPass(MVKCmdBeginRenderPass* mvkBeginRenderPass);

/** Update the last recorded multiview subpass */
void recordNextSubpass();
Expand Down
2 changes: 1 addition & 1 deletion MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
#pragma mark -
#pragma mark Multiview render pass command management

void MVKCommandBuffer::recordBeginRenderPass(MVKCmdBeginRenderPassBase* mvkBeginRenderPass) {
void MVKCommandBuffer::recordBeginRenderPass(MVKCmdBeginRenderPass* mvkBeginRenderPass) {
MVKRenderPass* mvkRendPass = mvkBeginRenderPass->getRenderPass();
_lastMultiviewSubpass = mvkRendPass->isMultiview() ? mvkRendPass->getSubpass(0) : nullptr;
}
Expand Down

0 comments on commit f9674d3

Please sign in to comment.