Browse Source

Vk: debug output for DynamicRasterizationState[s].

Will save them to a Pipeline and when there's a getter for something,
it's good to have a printer for it as well. Or at least for the tests.
pull/495/head
Vladimír Vondruš 5 years ago
parent
commit
ac62a6c708
  1. 25
      src/Magnum/Vk/Pipeline.cpp
  2. 12
      src/Magnum/Vk/RasterizationPipelineCreateInfo.h
  3. 18
      src/Magnum/Vk/Test/PipelineTest.cpp

25
src/Magnum/Vk/Pipeline.cpp

@ -29,6 +29,7 @@
#include "CommandBuffer.h"
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/BigEnumSet.hpp>
#include "Magnum/Vk/Assert.h"
#include "Magnum/Vk/Device.h"
@ -451,4 +452,28 @@ Debug& operator<<(Debug& debug, const PipelineBindPoint value) {
return debug << "(" << Debug::nospace << Int(value) << Debug::nospace << ")";
}
namespace {
constexpr const char* DynamicRasterizationStateNames[]{
#define _c(value, vkValue) #value,
#include "Magnum/Vk/Implementation/dynamicRasterizationStateMapping.hpp"
#undef _c
};
}
Debug& operator<<(Debug& debug, const DynamicRasterizationState value) {
debug << "Vk::DynamicRasterizationState" << Debug::nospace;
if(UnsignedInt(value) < Containers::arraySize(DynamicRasterizationStateNames)) {
return debug << "::" << Debug::nospace << DynamicRasterizationStateNames[UnsignedInt(value)];
}
return debug << "(" << Debug::nospace << reinterpret_cast<void*>(UnsignedByte(value)) << Debug::nospace << ")";
}
Debug& operator<<(Debug& debug, const DynamicRasterizationStates& value) {
return Containers::bigEnumSetDebugOutput(debug, value, "Vk::DynamicRasterizationStates{}");
}
}}

12
src/Magnum/Vk/RasterizationPipelineCreateInfo.h

@ -273,6 +273,18 @@ typedef Containers::BigEnumSet<DynamicRasterizationState, 1> DynamicRasterizatio
CORRADE_ENUMSET_OPERATORS(DynamicRasterizationStates)
/**
@debugoperatorenum{DynamicRasterizationState}
@m_since_latest
*/
MAGNUM_VK_EXPORT Debug& operator<<(Debug& debug, DynamicRasterizationState value);
/**
@debugoperatorenum{DynamicRasterizationState}
@m_since_latest
*/
MAGNUM_VK_EXPORT Debug& operator<<(Debug& debug, const DynamicRasterizationStates& value);
/**
@brief Rasterization pipeline creation info
@m_since_latest

18
src/Magnum/Vk/Test/PipelineTest.cpp

@ -84,6 +84,8 @@ struct PipelineTest: TestSuite::Tester {
void imageMemoryBarrierConstructFromVk();
void debugBindPoint();
void debugDynamicRasterizationState();
void debugDynamicRasterizationStates();
};
PipelineTest::PipelineTest() {
@ -124,7 +126,9 @@ PipelineTest::PipelineTest() {
&PipelineTest::imageMemoryBarrierConstructNoInit,
&PipelineTest::imageMemoryBarrierConstructFromVk,
&PipelineTest::debugBindPoint});
&PipelineTest::debugBindPoint,
&PipelineTest::debugDynamicRasterizationState,
&PipelineTest::debugDynamicRasterizationStates});
}
using namespace Containers::Literals;
@ -721,6 +725,18 @@ void PipelineTest::debugBindPoint() {
CORRADE_COMPARE(out.str(), "Vk::PipelineBindPoint::Compute Vk::PipelineBindPoint(-10007655)\n");
}
void PipelineTest::debugDynamicRasterizationState() {
std::ostringstream out;
Debug{&out} << DynamicRasterizationState::VertexInputBindingStride << DynamicRasterizationState(0xab);
CORRADE_COMPARE(out.str(), "Vk::DynamicRasterizationState::VertexInputBindingStride Vk::DynamicRasterizationState(0xab)\n");
}
void PipelineTest::debugDynamicRasterizationStates() {
std::ostringstream out;
Debug{&out} << (DynamicRasterizationState::Viewport|DynamicRasterizationState::Scissor|DynamicRasterizationState(0x2a)|DynamicRasterizationState(0x3f)) << DynamicRasterizationStates{};
CORRADE_COMPARE(out.str(), "Vk::DynamicRasterizationState::Viewport|Vk::DynamicRasterizationState::Scissor|Vk::DynamicRasterizationState(0x2a)|Vk::DynamicRasterizationState(0x3f) Vk::DynamicRasterizationStates{}\n");
}
}}}}
CORRADE_TEST_MAIN(Magnum::Vk::Test::PipelineTest)

Loading…
Cancel
Save