Commit 00424c1b by Ben Clayton

Reintroduce "VkDebug: Update macros to address issues in b/127433389"

36411219 had preprocessor issues on Windows. This should now work on all platforms. I had to change UNIMPLEMENTED() and UNREACHABLE() to always take a format parameter to make this work on MSVC. This doesn't seem like a terrible thing though - especially if we can incorporate the frequency of hit UNIMPLEMENTED()'s to steer our focus. Change-Id: Idc58dbe6caa3fb51e085c3b236904c640091deec Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/27468 Presubmit-Ready: Ben Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent c2bb50b7
......@@ -161,7 +161,7 @@ namespace sw
return false;
}
VkImageSubresourceLayers subresLayers =
VkImageSubresourceLayers subresLayers =
{
subresourceRange.aspectMask,
subresourceRange.baseMipLevel,
......@@ -341,14 +341,14 @@ namespace sw
case VK_FORMAT_R32_SFLOAT:
c.x = *Pointer<Float>(element);
break;
case VK_FORMAT_R16G16B16A16_SFLOAT:
c.w = Float(*Pointer<Half>(element + 6));
case VK_FORMAT_R16G16B16_SFLOAT:
c.z = Float(*Pointer<Half>(element + 4));
case VK_FORMAT_R16G16_SFLOAT:
c.y = Float(*Pointer<Half>(element + 2));
case VK_FORMAT_R16_SFLOAT:
c.x = Float(*Pointer<Half>(element));
case VK_FORMAT_R16G16B16A16_SFLOAT:
c.w = Float(*Pointer<Half>(element + 6));
case VK_FORMAT_R16G16B16_SFLOAT:
c.z = Float(*Pointer<Half>(element + 4));
case VK_FORMAT_R16G16_SFLOAT:
c.y = Float(*Pointer<Half>(element + 2));
case VK_FORMAT_R16_SFLOAT:
c.x = Float(*Pointer<Half>(element));
break;
case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
// 10 (or 11) bit float formats are unsigned formats with a 5 bit exponent and a 5 (or 6) bit mantissa.
......@@ -367,8 +367,8 @@ namespace sw
break;
case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
// This type contains a common 5 bit exponent (E) and a 9 bit the mantissa for R, G and B.
c.x = Float(*Pointer<UInt>(element) & UInt(0x000001FF)); // R's mantissa (bits 0-8)
c.y = Float((*Pointer<UInt>(element) & UInt(0x0003FE00)) >> 9); // G's mantissa (bits 9-17)
c.x = Float(*Pointer<UInt>(element) & UInt(0x000001FF)); // R's mantissa (bits 0-8)
c.y = Float((*Pointer<UInt>(element) & UInt(0x0003FE00)) >> 9); // G's mantissa (bits 9-17)
c.z = Float((*Pointer<UInt>(element) & UInt(0x07FC0000)) >> 18); // B's mantissa (bits 18-26)
c *= Float4(
// 2^E, using the exponent (bits 27-31) and treating it as an unsigned integer value
......@@ -467,10 +467,10 @@ namespace sw
case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
if(writeRGBA)
{
*Pointer<UShort>(element) = UShort(RoundInt(Float(c.w)) & Int(0xF)) |
UShort((RoundInt(Float(c.x)) & Int(0xF)) << 4) |
UShort((RoundInt(Float(c.y)) & Int(0xF)) << 8) |
UShort((RoundInt(Float(c.z)) & Int(0xF)) << 12);
*Pointer<UShort>(element) = UShort(RoundInt(Float(c.w)) & Int(0xF)) |
UShort((RoundInt(Float(c.x)) & Int(0xF)) << 4) |
UShort((RoundInt(Float(c.y)) & Int(0xF)) << 8) |
UShort((RoundInt(Float(c.z)) & Int(0xF)) << 12);
}
else
{
......@@ -480,9 +480,9 @@ namespace sw
(writeB ? 0xF000 : 0x0000);
unsigned short unmask = ~mask;
*Pointer<UShort>(element) = (*Pointer<UShort>(element) & UShort(unmask)) |
((UShort(RoundInt(Float(c.w)) & Int(0xF)) |
UShort((RoundInt(Float(c.x)) & Int(0xF)) << 4) |
UShort((RoundInt(Float(c.y)) & Int(0xF)) << 8) |
((UShort(RoundInt(Float(c.w)) & Int(0xF)) |
UShort((RoundInt(Float(c.x)) & Int(0xF)) << 4) |
UShort((RoundInt(Float(c.y)) & Int(0xF)) << 8) |
UShort((RoundInt(Float(c.z)) & Int(0xF)) << 12)) & UShort(mask));
}
break;
......@@ -565,14 +565,14 @@ namespace sw
case VK_FORMAT_R32_SFLOAT:
if(writeR) { *Pointer<Float>(element) = c.x; }
break;
case VK_FORMAT_R16G16B16A16_SFLOAT:
if(writeA) { *Pointer<Half>(element + 6) = Half(c.w); }
case VK_FORMAT_R16G16B16_SFLOAT:
if(writeB) { *Pointer<Half>(element + 4) = Half(c.z); }
case VK_FORMAT_R16G16_SFLOAT:
if(writeG) { *Pointer<Half>(element + 2) = Half(c.y); }
case VK_FORMAT_R16_SFLOAT:
if(writeR) { *Pointer<Half>(element) = Half(c.x); }
case VK_FORMAT_R16G16B16A16_SFLOAT:
if(writeA) { *Pointer<Half>(element + 6) = Half(c.w); }
case VK_FORMAT_R16G16B16_SFLOAT:
if(writeB) { *Pointer<Half>(element + 4) = Half(c.z); }
case VK_FORMAT_R16G16_SFLOAT:
if(writeG) { *Pointer<Half>(element + 2) = Half(c.y); }
case VK_FORMAT_R16_SFLOAT:
if(writeR) { *Pointer<Half>(element) = Half(c.x); }
break;
case VK_FORMAT_B8G8R8A8_SNORM:
if(writeB) { *Pointer<SByte>(element) = SByte(RoundInt(Float(c.z))); }
......@@ -1496,7 +1496,7 @@ namespace sw
if(!blitRoutine)
{
criticalSection.unlock();
UNIMPLEMENTED();
UNIMPLEMENTED("blitRoutine");
return nullptr;
}
......@@ -1518,7 +1518,7 @@ namespace sw
if((region.srcSubresource.layerCount != region.dstSubresource.layerCount) ||
(region.srcSubresource.aspectMask != region.dstSubresource.aspectMask))
{
UNIMPLEMENTED();
UNIMPLEMENTED("region");
}
if(region.dstOffsets[0].x > region.dstOffsets[1].x)
......
......@@ -279,7 +279,7 @@ namespace sw
mainBlockId = Block::ID(it.word(1));
break;
default:
ERR("Unexpected opcode '%s' following OpFunction", OpcodeName(it.opcode()).c_str());
WARN("Unexpected opcode '%s' following OpFunction", OpcodeName(it.opcode()).c_str());
}
}
ASSERT(mainBlockId.value() != 0); // Function's OpLabel not found
......@@ -424,7 +424,7 @@ namespace sw
break;
default:
UNIMPLEMENTED(OpcodeName(insn.opcode()).c_str());
UNIMPLEMENTED("%s", OpcodeName(insn.opcode()).c_str());
}
}
}
......@@ -1227,7 +1227,7 @@ namespace sw
break;
default:
UNIMPLEMENTED(OpcodeName(insn.opcode()).c_str());
UNIMPLEMENTED("opcode: %s", OpcodeName(insn.opcode()).c_str());
break;
}
}
......
......@@ -392,14 +392,14 @@ namespace sw
Type const &getType(Type::ID id) const
{
auto it = types.find(id);
ASSERT(it != types.end());
ASSERT_MSG(it != types.end(), "Unknown type %d", id.value());
return it->second;
}
Object const &getObject(Object::ID id) const
{
auto it = defs.find(id);
ASSERT(it != defs.end());
ASSERT_MSG(it != defs.end(), "Unknown object %d", id.value());
return it->second;
}
......
......@@ -601,7 +601,7 @@ VkResult CommandBuffer::begin(VkCommandBufferUsageFlags flags, const VkCommandBu
if(pInheritanceInfo)
{
UNIMPLEMENTED();
UNIMPLEMENTED("pInheritanceInfo");
}
if(state != INITIAL)
......@@ -646,7 +646,7 @@ void CommandBuffer::beginRenderPass(VkRenderPass renderPass, VkFramebuffer frame
if(contents != VK_SUBPASS_CONTENTS_INLINE)
{
UNIMPLEMENTED();
UNIMPLEMENTED("VK_SUBPASS_CONTENTS_INLINE");
}
addCommand<BeginRenderPass>(renderPass, framebuffer, renderArea, clearValueCount, clearValues);
......@@ -666,18 +666,18 @@ void CommandBuffer::endRenderPass()
void CommandBuffer::executeCommands(uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers)
{
UNIMPLEMENTED();
UNIMPLEMENTED("executeCommands");
}
void CommandBuffer::setDeviceMask(uint32_t deviceMask)
{
UNIMPLEMENTED();
UNIMPLEMENTED("setDeviceMask");
}
void CommandBuffer::dispatchBase(uint32_t baseGroupX, uint32_t baseGroupY, uint32_t baseGroupZ,
uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ)
{
UNIMPLEMENTED();
UNIMPLEMENTED("dispatchBase");
}
void CommandBuffer::pipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask,
......@@ -698,7 +698,7 @@ void CommandBuffer::bindPipeline(VkPipelineBindPoint pipelineBindPoint, VkPipeli
addCommand<PipelineBind>(pipelineBindPoint, pipeline);
break;
default:
UNIMPLEMENTED();
UNIMPLEMENTED("pipelineBindPoint");
}
}
......@@ -713,46 +713,46 @@ void CommandBuffer::bindVertexBuffers(uint32_t firstBinding, uint32_t bindingCou
void CommandBuffer::beginQuery(VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags)
{
UNIMPLEMENTED();
UNIMPLEMENTED("beginQuery");
}
void CommandBuffer::endQuery(VkQueryPool queryPool, uint32_t query)
{
UNIMPLEMENTED();
UNIMPLEMENTED("endQuery");
}
void CommandBuffer::resetQueryPool(VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount)
{
UNIMPLEMENTED();
UNIMPLEMENTED("resetQueryPool");
}
void CommandBuffer::writeTimestamp(VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query)
{
UNIMPLEMENTED();
UNIMPLEMENTED("writeTimestamp");
}
void CommandBuffer::copyQueryPoolResults(VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount,
VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags)
{
UNIMPLEMENTED();
UNIMPLEMENTED("copyQueryPoolResults");
}
void CommandBuffer::pushConstants(VkPipelineLayout layout, VkShaderStageFlags stageFlags,
uint32_t offset, uint32_t size, const void* pValues)
{
UNIMPLEMENTED();
UNIMPLEMENTED("pushConstants");
}
void CommandBuffer::setViewport(uint32_t firstViewport, uint32_t viewportCount, const VkViewport* pViewports)
{
// Note: The bound graphics pipeline must have been created with the VK_DYNAMIC_STATE_VIEWPORT dynamic state enabled
UNIMPLEMENTED();
UNIMPLEMENTED("setViewport");
}
void CommandBuffer::setScissor(uint32_t firstScissor, uint32_t scissorCount, const VkRect2D* pScissors)
{
// Note: The bound graphics pipeline must have been created with the VK_DYNAMIC_STATE_SCISSOR dynamic state enabled
UNIMPLEMENTED();
UNIMPLEMENTED("setScissor");
}
void CommandBuffer::setLineWidth(float lineWidth)
......@@ -762,7 +762,7 @@ void CommandBuffer::setLineWidth(float lineWidth)
// If the wide lines feature is not enabled, lineWidth must be 1.0
ASSERT(lineWidth == 1.0f);
UNIMPLEMENTED();
UNIMPLEMENTED("setLineWidth");
}
void CommandBuffer::setDepthBias(float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor)
......@@ -772,7 +772,7 @@ void CommandBuffer::setDepthBias(float depthBiasConstantFactor, float depthBiasC
// If the depth bias clamping feature is not enabled, depthBiasClamp must be 0.0
ASSERT(depthBiasClamp == 0.0f);
UNIMPLEMENTED();
UNIMPLEMENTED("setDepthBias");
}
void CommandBuffer::setBlendConstants(const float blendConstants[4])
......@@ -782,7 +782,7 @@ void CommandBuffer::setBlendConstants(const float blendConstants[4])
// blendConstants is an array of four values specifying the R, G, B, and A components
// of the blend constant color used in blending, depending on the blend factor.
UNIMPLEMENTED();
UNIMPLEMENTED("setBlendConstants");
}
void CommandBuffer::setDepthBounds(float minDepthBounds, float maxDepthBounds)
......@@ -793,7 +793,7 @@ void CommandBuffer::setDepthBounds(float minDepthBounds, float maxDepthBounds)
ASSERT(minDepthBounds >= 0.0f && minDepthBounds <= 1.0f);
ASSERT(maxDepthBounds >= 0.0f && maxDepthBounds <= 1.0f);
UNIMPLEMENTED();
UNIMPLEMENTED("setDepthBounds");
}
void CommandBuffer::setStencilCompareMask(VkStencilFaceFlags faceMask, uint32_t compareMask)
......@@ -803,7 +803,7 @@ void CommandBuffer::setStencilCompareMask(VkStencilFaceFlags faceMask, uint32_t
// faceMask must not be 0
ASSERT(faceMask != 0);
UNIMPLEMENTED();
UNIMPLEMENTED("setStencilCompareMask");
}
void CommandBuffer::setStencilWriteMask(VkStencilFaceFlags faceMask, uint32_t writeMask)
......@@ -813,7 +813,7 @@ void CommandBuffer::setStencilWriteMask(VkStencilFaceFlags faceMask, uint32_t wr
// faceMask must not be 0
ASSERT(faceMask != 0);
UNIMPLEMENTED();
UNIMPLEMENTED("setStencilWriteMask");
}
void CommandBuffer::setStencilReference(VkStencilFaceFlags faceMask, uint32_t reference)
......@@ -823,7 +823,7 @@ void CommandBuffer::setStencilReference(VkStencilFaceFlags faceMask, uint32_t re
// faceMask must not be 0
ASSERT(faceMask != 0);
UNIMPLEMENTED();
UNIMPLEMENTED("setStencilReference");
}
void CommandBuffer::bindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout,
......@@ -834,7 +834,7 @@ void CommandBuffer::bindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, Vk
if(dynamicOffsetCount > 0)
{
UNIMPLEMENTED();
UNIMPLEMENTED("bindDescriptorSets");
}
for(uint32_t i = 0; i < descriptorSetCount; i++)
......@@ -855,7 +855,7 @@ void CommandBuffer::dispatch(uint32_t groupCountX, uint32_t groupCountY, uint32_
void CommandBuffer::dispatchIndirect(VkBuffer buffer, VkDeviceSize offset)
{
UNIMPLEMENTED();
UNIMPLEMENTED("dispatchIndirect");
}
void CommandBuffer::copyBuffer(VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy* pRegions)
......@@ -974,7 +974,7 @@ void CommandBuffer::clearAttachments(uint32_t attachmentCount, const VkClearAtta
void CommandBuffer::resolveImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout,
uint32_t regionCount, const VkImageResolve* pRegions)
{
UNIMPLEMENTED();
UNIMPLEMENTED("resolveImage");
}
void CommandBuffer::setEvent(VkEvent event, VkPipelineStageFlags stageMask)
......@@ -996,7 +996,7 @@ void CommandBuffer::waitEvents(uint32_t eventCount, const VkEvent* pEvents, VkPi
uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers,
uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers)
{
UNIMPLEMENTED();
UNIMPLEMENTED("waitEvents");
}
void CommandBuffer::draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
......@@ -1011,12 +1011,12 @@ void CommandBuffer::drawIndexed(uint32_t indexCount, uint32_t instanceCount, uin
void CommandBuffer::drawIndirect(VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
{
UNIMPLEMENTED();
UNIMPLEMENTED("drawIndirect");
}
void CommandBuffer::drawIndexedIndirect(VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
{
UNIMPLEMENTED();
UNIMPLEMENTED("drawIndexedIndirect");
}
void CommandBuffer::submit(CommandBuffer::ExecutionState& executionState)
......
......@@ -14,25 +14,61 @@
#include "VkDebug.hpp"
#include <string>
#include <stdarg.h>
namespace vk
{
void trace(const char *format, ...)
void tracev(const char *format, va_list args)
{
#ifndef SWIFTSHADER_DISABLE_TRACE
if(false)
{
FILE *file = fopen("debug.txt", "a");
FILE *file = fopen(TRACE_OUTPUT_FILE, "a");
if(file)
{
va_list vararg;
va_start(vararg, format);
vfprintf(file, format, vararg);
va_end(vararg);
vfprintf(file, format, args);
fclose(file);
}
}
#endif
}
void trace(const char *format, ...)
{
va_list vararg;
va_start(vararg, format);
tracev(format, vararg);
va_end(vararg);
}
void warn(const char *format, ...)
{
va_list vararg;
va_start(vararg, format);
tracev(format, vararg);
va_end(vararg);
va_start(vararg, format);
vfprintf(stderr, format, vararg);
va_end(vararg);
}
void abort(const char *format, ...)
{
va_list vararg;
va_start(vararg, format);
tracev(format, vararg);
va_end(vararg);
va_start(vararg, format);
vfprintf(stderr, format, vararg);
va_end(vararg);
::abort();
}
}
......@@ -27,77 +27,85 @@
namespace vk
{
// Outputs text to the debugging log
void trace(const char *format, ...);
inline void trace() {}
// Outputs text to the debugging log
void trace(const char *format, ...);
inline void trace() {}
// Outputs text to the debugging log and prints to stderr.
void warn(const char *format, ...);
inline void warn() {}
// Outputs the message to the debugging log and stderr, and calls abort().
void abort(const char *format, ...);
}
// A macro to output a trace of a function call and its arguments to the debugging log
// A macro to output a trace of a function call and its arguments to the
// debugging log. Disabled if SWIFTSHADER_DISABLE_TRACE is defined.
#if defined(SWIFTSHADER_DISABLE_TRACE)
#define TRACE(message, ...) (void(0))
#else
#define TRACE(message, ...) vk::trace("trace: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
#define TRACE(message, ...) vk::trace("%s:%d TRACE: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__)
#endif
// A macro to output a function call and its arguments to the debugging log, to denote an item in need of fixing.
#if defined(SWIFTSHADER_DISABLE_TRACE)
#define FIXME(message, ...) (void(0))
#else
#define FIXME(message, ...) do {vk::trace("fixme: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); assert(false); abort();} while(false)
#endif
// A macro to print a warning message to the debugging log and stderr to denote
// an issue that needs fixing.
#define FIXME(message, ...) vk::warn("%s:%d FIXME: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__);
// A macro to output a function call and its arguments to the debugging log, in case of error.
#if defined(SWIFTSHADER_DISABLE_TRACE)
#define ERR(message, ...) (void(0))
// A macro to print a warning message to the debugging log and stderr.
#define WARN(message, ...) vk::warn("%s:%d WARNING: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__);
// A macro that prints the message to the debugging log and stderr and
// immediately aborts execution of the application.
//
// Note: This will terminate the application regardless of build flags!
// Use with extreme caution!
#undef ABORT
#define ABORT(message, ...) vk::abort("%s:%d ABORT: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__)
// A macro that delegates to:
// ABORT() in debug builds (!NDEBUG || DCHECK_ALWAYS_ON)
// or
// WARN() in release builds (NDEBUG && !DCHECK_ALWAYS_ON)
#undef DABORT
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define DABORT(message, ...) ABORT(message, ##__VA_ARGS__)
#else
#define ERR(message, ...) do {vk::trace("err: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); assert(false); abort();} while(false)
#define DABORT(message, ...) WARN(message, ##__VA_ARGS__)
#endif
// A macro asserting a condition and outputting failures to the debug log
// A macro asserting a condition.
// If the condition fails, the condition and message is passed to DABORT().
#undef ASSERT_MSG
#define ASSERT_MSG(expression, format, ...) do { \
if(!(expression)) { \
DABORT("ASSERT(%s): " format "\n", #expression, ##__VA_ARGS__); \
} } while(0)
// A macro asserting a condition.
// If the condition fails, the condition is passed to DABORT().
#undef ASSERT
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define ASSERT(expression) do { \
if(!(expression)) { \
ERR("\t! Assert failed in %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \
assert(expression); \
abort(); \
DABORT("ASSERT(%s)\n", #expression); \
} } while(0)
#else
#define ASSERT(expression) (void(0))
#endif
// A macro to indicate unimplemented functionality
// A macro to indicate unimplemented functionality.
#undef UNIMPLEMENTED
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define UNIMPLEMENTED(...) do { \
vk::trace("\t! Unimplemented: %s(%d): ", __FUNCTION__, __LINE__); \
vk::trace(__VA_ARGS__); \
vk::trace("\n"); \
assert(false); \
abort(); \
} while(0)
#else
#define UNIMPLEMENTED(...) FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__)
#endif
#define UNIMPLEMENTED(format, ...) DABORT("UNIMPLEMENTED: " format, ##__VA_ARGS__)
// A macro for code which is not expected to be reached under valid assumptions
// A macro for code which is not expected to be reached under valid assumptions.
#undef UNREACHABLE
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define UNREACHABLE(value) do { \
ERR("\t! Unreachable case reached: %s(%d). %s: %d\n", __FUNCTION__, __LINE__, #value, value); \
assert(false); \
abort(); \
} while(0)
#else
#define UNREACHABLE(value) ERR("\t! Unreachable reached: %s(%d). %s: %d\n", __FUNCTION__, __LINE__, #value, value)
#endif
#define UNREACHABLE(format, ...) DABORT("UNREACHABLE: " format, ##__VA_ARGS__)
// A macro asserting a condition and outputting failures to the debug log, or return when in release mode.
// A macro asserting a condition and performing a return.
#undef ASSERT_OR_RETURN
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define ASSERT_OR_RETURN(expression) ASSERT(expression)
#else
#define ASSERT_OR_RETURN(expression) do { \
if(!(expression)) { \
ASSERT(expression); \
return; \
} } while(0)
#endif
#endif // VK_DEBUG_H_
......@@ -204,7 +204,7 @@ const uint8_t* DescriptorSetLayout::GetInputData(const VkWriteDescriptorSet& des
return reinterpret_cast<const uint8_t*>(descriptorWrites.pBufferInfo);
break;
default:
UNIMPLEMENTED();
UNIMPLEMENTED("descriptorType");
return nullptr;
}
}
......
......@@ -49,7 +49,7 @@ Device::Device(const Device::CreateInfo* info, void* mem)
if(pCreateInfo->enabledLayerCount)
{
// "The ppEnabledLayerNames and enabledLayerCount members of VkDeviceCreateInfo are deprecated and their values must be ignored by implementations."
UNIMPLEMENTED(); // TODO(b/119321052): UNIMPLEMENTED() should be used only for features that must still be implemented. Use a more informational macro here.
UNIMPLEMENTED("enabledLayerCount"); // TODO(b/119321052): UNIMPLEMENTED() should be used only for features that must still be implemented. Use a more informational macro here.
}
blitter = new sw::Blitter();
......@@ -90,12 +90,12 @@ void Device::waitForFences(uint32_t fenceCount, const VkFence* pFences, VkBool32
// FIXME(b/117835459) : noop
}
void Device::waitIdle()
{
for(uint32_t i = 0; i < queueCount; i++)
{
queues[i].waitIdle();
}
void Device::waitIdle()
{
for(uint32_t i = 0; i < queueCount; i++)
{
queues[i].waitIdle();
}
}
void Device::getDescriptorSetLayoutSupport(const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
......
......@@ -89,7 +89,7 @@ void Image::getSubresourceLayout(const VkImageSubresource* pSubresource, VkSubre
(pSubresource->aspectMask == VK_IMAGE_ASPECT_DEPTH_BIT) ||
(pSubresource->aspectMask == VK_IMAGE_ASPECT_STENCIL_BIT)))
{
UNIMPLEMENTED();
UNIMPLEMENTED("aspectMask");
}
auto aspect = static_cast<VkImageAspectFlagBits>(pSubresource->aspectMask);
pLayout->offset = getMemoryOffset(aspect, pSubresource->mipLevel, pSubresource->arrayLayer);
......@@ -111,7 +111,7 @@ void Image::copyTo(VkImage dstImage, const VkImageCopy& pRegion)
(pRegion.srcSubresource.baseArrayLayer != 0) ||
(pRegion.srcSubresource.layerCount != 1))
{
UNIMPLEMENTED();
UNIMPLEMENTED("srcSubresource");
}
if(!((pRegion.dstSubresource.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT) ||
......@@ -120,7 +120,7 @@ void Image::copyTo(VkImage dstImage, const VkImageCopy& pRegion)
(pRegion.dstSubresource.baseArrayLayer != 0) ||
(pRegion.dstSubresource.layerCount != 1))
{
UNIMPLEMENTED();
UNIMPLEMENTED("dstSubresource");
}
VkImageAspectFlagBits srcAspect = static_cast<VkImageAspectFlagBits>(pRegion.srcSubresource.aspectMask);
......@@ -210,7 +210,7 @@ void Image::copy(VkBuffer buf, const VkBufferImageCopy& region, bool bufferIsSou
(region.imageSubresource.aspectMask == VK_IMAGE_ASPECT_DEPTH_BIT) ||
(region.imageSubresource.aspectMask == VK_IMAGE_ASPECT_STENCIL_BIT)))
{
UNIMPLEMENTED();
UNIMPLEMENTED("imageSubresource");
}
VkImageAspectFlagBits aspect = static_cast<VkImageAspectFlagBits>(region.imageSubresource.aspectMask);
......@@ -541,7 +541,7 @@ void Image::clear(void* pixelData, VkFormat format, const VkImageSubresourceRang
if((subresourceRange.baseMipLevel != 0) ||
(subresourceRange.levelCount != 1))
{
UNIMPLEMENTED();
UNIMPLEMENTED("subresourceRange");
}
device->getBlitter()->clear(pixelData, format, this, subresourceRange, &renderArea);
......@@ -551,7 +551,7 @@ void Image::clear(const VkClearColorValue& color, const VkImageSubresourceRange&
{
if(!(subresourceRange.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT))
{
UNIMPLEMENTED();
UNIMPLEMENTED("aspectMask");
}
device->getBlitter()->clear((void*)color.float32, getClearFormat(), this, subresourceRange);
......@@ -562,7 +562,7 @@ void Image::clear(const VkClearDepthStencilValue& color, const VkImageSubresourc
if((subresourceRange.aspectMask & ~(VK_IMAGE_ASPECT_DEPTH_BIT |
VK_IMAGE_ASPECT_STENCIL_BIT)) != 0)
{
UNIMPLEMENTED();
UNIMPLEMENTED("aspectMask");
}
if(subresourceRange.aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT)
......@@ -588,7 +588,7 @@ void Image::clear(const VkClearValue& clearValue, const VkRect2D& renderArea, co
(subresourceRange.baseMipLevel != 0) ||
(subresourceRange.levelCount != 1))
{
UNIMPLEMENTED();
UNIMPLEMENTED("subresourceRange");
}
if(subresourceRange.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT)
......
......@@ -84,12 +84,12 @@ void ImageView::clear(const VkClearValue& clearValue, const VkImageAspectFlags a
if(!imageTypesMatch(image->getImageType()))
{
UNIMPLEMENTED();
UNIMPLEMENTED("imageTypesMatch");
}
if(image->getFormat() != format)
{
UNIMPLEMENTED();
UNIMPLEMENTED("format");
}
VkImageSubresourceRange sr = subresourceRange;
......@@ -103,12 +103,12 @@ void ImageView::clear(const VkClearValue& clearValue, const VkImageAspectFlags a
if(!imageTypesMatch(image->getImageType()))
{
UNIMPLEMENTED();
UNIMPLEMENTED("imageTypesMatch");
}
if(image->getFormat() != format)
{
UNIMPLEMENTED();
UNIMPLEMENTED("format");
}
VkImageSubresourceRange sr;
......
......@@ -655,7 +655,7 @@ void PhysicalDevice::getImageFormatProperties(VkFormat format, VkImageType type,
pImageFormatProperties->maxArrayLayers = 1; // no 3D + layers
break;
default:
UNREACHABLE(type);
UNREACHABLE("VkImageType: %d", int(type));
break;
}
......
......@@ -53,7 +53,7 @@ sw::DrawType Convert(VkPrimitiveTopology topology)
ASSERT(false);
break;
default:
UNIMPLEMENTED();
UNIMPLEMENTED("topology");
}
return sw::DRAW_TRIANGLELIST;
......@@ -119,7 +119,7 @@ sw::StreamType getStreamType(VkFormat format)
case VK_FORMAT_R32G32B32A32_SFLOAT:
return sw::STREAMTYPE_FLOAT;
default:
UNIMPLEMENTED();
UNIMPLEMENTED("format");
}
return sw::STREAMTYPE_BYTE;
......@@ -179,7 +179,7 @@ uint32_t getNumberOfChannels(VkFormat format)
case VK_FORMAT_R32G32B32A32_SFLOAT:
return 4;
default:
UNIMPLEMENTED();
UNIMPLEMENTED("format");
}
return 0;
......@@ -194,19 +194,17 @@ std::vector<uint32_t> preprocessSpirv(
spvtools::Optimizer opt{SPV_ENV_VULKAN_1_1};
opt.SetMessageConsumer([](spv_message_level_t level, const char*, const spv_position_t& p, const char* m) {
const char* category = "";
switch (level)
{
case SPV_MSG_FATAL:
case SPV_MSG_INTERNAL_ERROR:
case SPV_MSG_ERROR:
ERR("%d:%d %s", p.line, p.column, m);
break;
case SPV_MSG_WARNING:
case SPV_MSG_INFO:
case SPV_MSG_DEBUG:
TRACE("%d:%d %s", p.line, p.column, m);
break;
case SPV_MSG_FATAL: category = "FATAL"; break;
case SPV_MSG_INTERNAL_ERROR: category = "INTERNAL_ERROR"; break;
case SPV_MSG_ERROR: category = "ERROR"; break;
case SPV_MSG_WARNING: category = "WARNING"; break;
case SPV_MSG_INFO: category = "INFO"; break;
case SPV_MSG_DEBUG: category = "DEBUG"; break;
}
vk::trace("%s: %d:%d %s", category, p.line, p.column, m);
});
opt.RegisterPass(spvtools::CreateInlineExhaustivePass());
......@@ -264,13 +262,13 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
(pCreateInfo->basePipelineHandle != VK_NULL_HANDLE) ||
(pCreateInfo->basePipelineIndex != 0))
{
UNIMPLEMENTED();
UNIMPLEMENTED("pCreateInfo settings");
}
const VkPipelineVertexInputStateCreateInfo* vertexInputState = pCreateInfo->pVertexInputState;
if(vertexInputState->flags != 0)
{
UNIMPLEMENTED();
UNIMPLEMENTED("vertexInputState->flags");
}
// Context must always have a PipelineLayout set.
......@@ -285,7 +283,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
bufferStrides[desc.binding] = desc.stride;
if(desc.inputRate != VK_VERTEX_INPUT_RATE_VERTEX)
{
UNIMPLEMENTED();
UNIMPLEMENTED("vertexInputState->pVertexBindingDescriptions[%d]", i);
}
}
......@@ -305,7 +303,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
if((assemblyState->flags != 0) ||
(assemblyState->primitiveRestartEnable != 0))
{
UNIMPLEMENTED();
UNIMPLEMENTED("pCreateInfo->pInputAssemblyState settings");
}
context.drawType = Convert(assemblyState->topology);
......@@ -317,7 +315,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
(viewportState->viewportCount != 1) ||
(viewportState->scissorCount != 1))
{
UNIMPLEMENTED();
UNIMPLEMENTED("pCreateInfo->pViewportState settings");
}
scissor = viewportState->pScissors[0];
......@@ -329,7 +327,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
(rasterizationState->depthClampEnable != 0) ||
(rasterizationState->polygonMode != VK_POLYGON_MODE_FILL))
{
UNIMPLEMENTED();
UNIMPLEMENTED("pCreateInfo->pRasterizationState settings");
}
context.rasterizerDiscard = rasterizationState->rasterizerDiscardEnable;
......@@ -359,7 +357,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
(multisampleState->alphaToCoverageEnable != 0) ||
(multisampleState->alphaToOneEnable != 0))
{
UNIMPLEMENTED();
UNIMPLEMENTED("multisampleState");
}
}
else
......@@ -373,7 +371,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
if((depthStencilState->flags != 0) ||
(depthStencilState->depthBoundsTestEnable != 0))
{
UNIMPLEMENTED();
UNIMPLEMENTED("depthStencilState");
}
context.depthBufferEnable = depthStencilState->depthTestEnable;
......@@ -408,7 +406,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
((colorBlendState->logicOpEnable != 0) &&
(colorBlendState->attachmentCount > 1)))
{
UNIMPLEMENTED();
UNIMPLEMENTED("colorBlendState");
}
blendConstants.r = colorBlendState->blendConstants[0];
......@@ -421,7 +419,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
const VkPipelineColorBlendAttachmentState& attachment = colorBlendState->pAttachments[0];
if(attachment.colorWriteMask != (VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT))
{
UNIMPLEMENTED();
UNIMPLEMENTED("colorWriteMask");
}
context.alphaBlendEnable = attachment.blendEnable;
......@@ -455,7 +453,7 @@ void GraphicsPipeline::compileShaders(const VkAllocationCallbacks* pAllocator, c
{
if (pStage->flags != 0)
{
UNIMPLEMENTED();
UNIMPLEMENTED("pStage->flags");
}
auto module = Cast(pStage->module);
......@@ -497,7 +495,7 @@ uint32_t GraphicsPipeline::computePrimitiveCount(uint32_t vertexCount) const
case sw::DRAW_TRIANGLEFAN:
return vertexCount - 2;
default:
UNIMPLEMENTED();
UNIMPLEMENTED("drawType");
}
return 0;
......
......@@ -27,7 +27,7 @@ namespace vk
// pipelineStatistics member of the VkQueryPoolCreateInfo structure."
if(pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS)
{
UNIMPLEMENTED();
UNIMPLEMENTED("pCreateInfo->queryType");
}
}
......@@ -48,7 +48,7 @@ namespace vk
char* data = static_cast<char*>(pData);
for(uint32_t i = 0; i < pQueryCount; i++, data += pStride)
{
UNIMPLEMENTED();
UNIMPLEMENTED("queries");
}
}
} // namespace vk
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment