Move definitions of operator<< overload in their own cpp

also always include these definitions on debug builds
This commit is contained in:
Mathias Agopian
2021-08-23 15:23:56 -07:00
committed by Mathias Agopian
parent 9cea332f61
commit 3f26c8b893
9 changed files with 557 additions and 534 deletions
+1
View File
@@ -27,6 +27,7 @@ set(SRCS
src/Driver.cpp
src/Handle.cpp
src/HandleAllocator.cpp
src/ostream.cpp
src/noop/NoopDriver.cpp
src/noop/PlatformNoop.cpp
src/Platform.cpp
@@ -20,12 +20,12 @@
#define TNT_FILAMENT_BACKEND_BUFFERDESCRIPTOR_H
#include <utils/compiler.h>
#include <utils/ostream.h>
#include <stddef.h>
#include <stdint.h>
namespace filament {
namespace backend {
namespace filament::backend {
/**
* A CPU memory-buffer descriptor, typically used to transfer data from the CPU to the GPU.
@@ -126,7 +126,10 @@ private:
void* user = nullptr;
};
} // namespace backend
} // namespace filament
} // namespace filament::backend
#if !defined(NDEBUG)
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::BufferDescriptor& b);
#endif
#endif // TNT_FILAMENT_BACKEND_BUFFERDESCRIPTOR_H
@@ -24,6 +24,8 @@
#include <backend/PresentCallable.h>
#include <utils/ostream.h>
#include <math/vec4.h>
#include <array> // FIXME: STL headers are not allowed in public headers
@@ -926,4 +928,36 @@ template<> struct utils::EnableBitMaskOperators<filament::backend::TargetBufferF
template<> struct utils::EnableBitMaskOperators<filament::backend::TextureUsage>
: public std::true_type {};
#if !defined(NDEBUG)
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::BufferUsage usage);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::CullingMode mode);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::ElementType type);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::PixelDataFormat format);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::PixelDataType type);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::Precision precision);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::PrimitiveType type);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::TargetBufferFlags f);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::SamplerCompareFunc func);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::SamplerCompareMode mode);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::SamplerFormat format);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::SamplerMagFilter filter);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::SamplerMinFilter filter);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::SamplerParams params);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::SamplerType type);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::SamplerWrapMode wrap);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::ShaderModel model);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::TextureCubemapFace face);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::TextureFormat format);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::TextureUsage usage);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::BufferObjectBinding binding);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::TextureSwizzle swizzle);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::AttributeArray& type);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::FaceOffsets& type);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::PolygonOffset& po);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::RasterState& rs);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::RenderPassParams& b);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::Viewport& v);
#endif
#endif // TNT_FILAMENT_BACKEND_DRIVERENUMS_H
@@ -24,8 +24,7 @@
#include <stdint.h>
namespace filament {
namespace backend {
namespace filament::backend {
//! \privatesection
@@ -39,8 +38,10 @@ struct PipelineState {
};
};
} // namespace filament::backend
} // namespace backend
} // namespace filament
#if !defined(NDEBUG)
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::PipelineState& ps);
#endif
#endif //TNT_FILAMENT_BACKEND_PIPELINESTATE_H
@@ -213,4 +213,8 @@ public:
} // namespace backend
} // namespace filament
#if !defined(NDEBUG)
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::PixelBufferDescriptor& b);
#endif
#endif // TNT_FILAMENT_BACKEND_PIXELBUFFERDESCRIPTOR_H
@@ -104,4 +104,9 @@ public:
} // namespace backend
} // namespace filament
#if !defined(NDEBUG)
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::TargetBufferInfo& tbi);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::MRT& mrt);
#endif
#endif //TNT_FILAMENT_BACKEND_TARGETBUFFERINFO_H
@@ -18,6 +18,7 @@
#define TNT_FILAMENT_BACKEND_PRIVATE_DRIVER_H
#include <backend/BufferDescriptor.h>
#include <backend/DriverEnums.h>
#include <backend/Handle.h>
#include <backend/PipelineState.h>
#include <backend/PixelBufferDescriptor.h>
@@ -28,8 +29,6 @@
#include "private/backend/Program.h"
#include "private/backend/SamplerGroup.h"
#include <backend/DriverEnums.h>
#include <utils/compiler.h>
#include <utils/Log.h>
@@ -104,43 +103,4 @@ public:
} // namespace backend
} // namespace filament
#if !defined(NDEBUG)
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::BufferUsage usage);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::CullingMode mode);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::ElementType type);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::PixelDataFormat format);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::PixelDataType type);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::Precision precision);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::PrimitiveType type);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::TargetBufferFlags f);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::SamplerCompareFunc func);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::SamplerCompareMode mode);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::SamplerFormat format);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::SamplerMagFilter filter);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::SamplerMinFilter filter);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::SamplerParams params);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::SamplerType type);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::SamplerWrapMode wrap);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::ShaderModel model);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::TextureCubemapFace face);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::TextureFormat format);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::TextureUsage usage);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::BufferObjectBinding binding);
utils::io::ostream& operator<<(utils::io::ostream& out, filament::backend::TextureSwizzle swizzle);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::AttributeArray& type);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::FaceOffsets& type);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::PolygonOffset& po);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::PipelineState& ps);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::RasterState& rs);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::TargetBufferInfo& tbi);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::BufferDescriptor& b);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::PixelBufferDescriptor& b);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::RenderPassParams& b);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::Viewport& v);
utils::io::ostream& operator<<(utils::io::ostream& out, const filament::backend::MRT& mrt);
#endif
#endif // TNT_FILAMENT_BACKEND_PRIVATE_DRIVER_H
-485
View File
@@ -154,488 +154,3 @@ void CustomCommand::execute(Driver&, CommandBase* base, intptr_t* next) noexcept
} // namespace backend
} // namespace filament
// ------------------------------------------------------------------------------------------------
// Stream operators for all types in DriverEnums.h
// (These must live outside of the filament namespace)
// ------------------------------------------------------------------------------------------------
using namespace filament;
using namespace backend;
#if !defined(NDEBUG) && (DEBUG_COMMAND_STREAM != false)
#define CASE(ENUM, VALUE) \
case ENUM::VALUE: { \
out << #VALUE; \
break; \
}
io::ostream& operator<<(io::ostream& out, ShaderModel model) {
switch (model) {
CASE(ShaderModel, UNKNOWN)
CASE(ShaderModel, GL_ES_30)
CASE(ShaderModel, GL_CORE_41)
}
return out;
}
io::ostream& operator<<(io::ostream& out, PrimitiveType type) {
switch (type) {
CASE(PrimitiveType, TRIANGLES)
CASE(PrimitiveType, LINES)
CASE(PrimitiveType, POINTS)
CASE(PrimitiveType, NONE)
}
return out;
}
io::ostream& operator<<(io::ostream& out, ElementType type) {
switch (type) {
CASE(ElementType, BYTE)
CASE(ElementType, BYTE2)
CASE(ElementType, BYTE3)
CASE(ElementType, BYTE4)
CASE(ElementType, UBYTE)
CASE(ElementType, UBYTE2)
CASE(ElementType, UBYTE3)
CASE(ElementType, UBYTE4)
CASE(ElementType, SHORT)
CASE(ElementType, SHORT2)
CASE(ElementType, SHORT3)
CASE(ElementType, SHORT4)
CASE(ElementType, USHORT)
CASE(ElementType, USHORT2)
CASE(ElementType, USHORT3)
CASE(ElementType, USHORT4)
CASE(ElementType, INT)
CASE(ElementType, UINT)
CASE(ElementType, FLOAT)
CASE(ElementType, FLOAT2)
CASE(ElementType, FLOAT3)
CASE(ElementType, FLOAT4)
CASE(ElementType, HALF)
CASE(ElementType, HALF2)
CASE(ElementType, HALF3)
CASE(ElementType, HALF4)
}
return out;
}
io::ostream& operator<<(io::ostream& out, BufferUsage usage) {
switch (usage) {
CASE(BufferUsage, STATIC)
CASE(BufferUsage, DYNAMIC)
CASE(BufferUsage, STREAM)
}
return out;
}
io::ostream& operator<<(io::ostream& out, CullingMode mode) {
switch (mode) {
CASE(CullingMode, NONE)
CASE(CullingMode, FRONT)
CASE(CullingMode, BACK)
CASE(CullingMode, FRONT_AND_BACK)
}
return out;
}
io::ostream& operator<<(io::ostream& out, SamplerType type) {
switch (type) {
CASE(SamplerType, SAMPLER_2D)
CASE(SamplerType, SAMPLER_2D_ARRAY)
CASE(SamplerType, SAMPLER_3D)
CASE(SamplerType, SAMPLER_CUBEMAP)
CASE(SamplerType, SAMPLER_EXTERNAL)
}
return out;
}
io::ostream& operator<<(io::ostream& out, SamplerFormat type) {
switch (type) {
CASE(SamplerFormat, INT)
CASE(SamplerFormat, UINT)
CASE(SamplerFormat, FLOAT)
CASE(SamplerFormat, SHADOW)
}
return out;
}
io::ostream& operator<<(io::ostream& out, Precision precision) {
switch (precision) {
CASE(Precision, LOW)
CASE(Precision, MEDIUM)
CASE(Precision, HIGH)
CASE(Precision, DEFAULT)
}
return out;
}
io::ostream& operator<<(io::ostream& out, PixelDataFormat format) {
switch (format) {
CASE(PixelDataFormat, R)
CASE(PixelDataFormat, R_INTEGER)
CASE(PixelDataFormat, RG)
CASE(PixelDataFormat, RG_INTEGER)
CASE(PixelDataFormat, RGB)
CASE(PixelDataFormat, RGB_INTEGER)
CASE(PixelDataFormat, RGBA)
CASE(PixelDataFormat, RGBA_INTEGER)
CASE(PixelDataFormat, DEPTH_COMPONENT)
CASE(PixelDataFormat, DEPTH_STENCIL)
CASE(PixelDataFormat, ALPHA)
CASE(PixelDataFormat, UNUSED)
}
return out;
}
io::ostream& operator<<(io::ostream& out, PixelDataType format) {
switch (format) {
CASE(PixelDataType, UBYTE)
CASE(PixelDataType, BYTE)
CASE(PixelDataType, USHORT)
CASE(PixelDataType, SHORT)
CASE(PixelDataType, UINT)
CASE(PixelDataType, INT)
CASE(PixelDataType, HALF)
CASE(PixelDataType, FLOAT)
CASE(PixelDataType, COMPRESSED)
CASE(PixelDataType, UINT_10F_11F_11F_REV)
CASE(PixelDataType, USHORT_565)
CASE(PixelDataType, UINT_2_10_10_10_REV)
}
return out;
}
io::ostream& operator<<(io::ostream& out, TextureFormat format) {
switch (format) {
CASE(TextureFormat, R8)
CASE(TextureFormat, R8_SNORM)
CASE(TextureFormat, R16F)
CASE(TextureFormat, R32F)
CASE(TextureFormat, R8UI)
CASE(TextureFormat, R8I)
CASE(TextureFormat, STENCIL8)
CASE(TextureFormat, R16UI)
CASE(TextureFormat, R16I)
CASE(TextureFormat, R32UI)
CASE(TextureFormat, R32I)
CASE(TextureFormat, RG8)
CASE(TextureFormat, RG8_SNORM)
CASE(TextureFormat, RG16F)
CASE(TextureFormat, RG32F)
CASE(TextureFormat, RG8UI)
CASE(TextureFormat, RG8I)
CASE(TextureFormat, RG16UI)
CASE(TextureFormat, RG16I)
CASE(TextureFormat, RG32UI)
CASE(TextureFormat, RG32I)
CASE(TextureFormat, RGB8)
CASE(TextureFormat, SRGB8)
CASE(TextureFormat, RGB565)
CASE(TextureFormat, RGB8_SNORM)
CASE(TextureFormat, R11F_G11F_B10F)
CASE(TextureFormat, RGB9_E5)
CASE(TextureFormat, RGB16F)
CASE(TextureFormat, RGB32F)
CASE(TextureFormat, RGB8UI)
CASE(TextureFormat, RGB8I)
CASE(TextureFormat, RGB16UI)
CASE(TextureFormat, RGB16I)
CASE(TextureFormat, RGB32UI)
CASE(TextureFormat, RGB32I)
CASE(TextureFormat, RGBA8)
CASE(TextureFormat, SRGB8_A8)
CASE(TextureFormat, RGBA8_SNORM)
CASE(TextureFormat, RGB5_A1)
CASE(TextureFormat, RGBA4)
CASE(TextureFormat, RGB10_A2)
CASE(TextureFormat, RGBA16F)
CASE(TextureFormat, RGBA32F)
CASE(TextureFormat, RGBA8UI)
CASE(TextureFormat, RGBA8I)
CASE(TextureFormat, RGBA16UI)
CASE(TextureFormat, RGBA16I)
CASE(TextureFormat, RGBA32UI)
CASE(TextureFormat, RGBA32I)
CASE(TextureFormat, DEPTH16)
CASE(TextureFormat, DEPTH24)
CASE(TextureFormat, DEPTH32F)
CASE(TextureFormat, DEPTH24_STENCIL8)
CASE(TextureFormat, DEPTH32F_STENCIL8)
// compressed formats...
CASE(TextureFormat, EAC_R11)
CASE(TextureFormat, EAC_R11_SIGNED)
CASE(TextureFormat, EAC_RG11)
CASE(TextureFormat, EAC_RG11_SIGNED)
CASE(TextureFormat, ETC2_RGB8)
CASE(TextureFormat, ETC2_SRGB8)
CASE(TextureFormat, ETC2_RGB8_A1)
CASE(TextureFormat, ETC2_SRGB8_A1)
CASE(TextureFormat, ETC2_EAC_RGBA8)
CASE(TextureFormat, ETC2_EAC_SRGBA8)
CASE(TextureFormat, DXT1_RGB)
CASE(TextureFormat, DXT1_SRGB)
CASE(TextureFormat, DXT1_RGBA)
CASE(TextureFormat, DXT1_SRGBA)
CASE(TextureFormat, DXT3_RGBA)
CASE(TextureFormat, DXT3_SRGBA)
CASE(TextureFormat, DXT5_RGBA)
CASE(TextureFormat, DXT5_SRGBA)
CASE(TextureFormat, UNUSED)
CASE(TextureFormat, RGBA_ASTC_4x4)
CASE(TextureFormat, RGBA_ASTC_5x4)
CASE(TextureFormat, RGBA_ASTC_5x5)
CASE(TextureFormat, RGBA_ASTC_6x5)
CASE(TextureFormat, RGBA_ASTC_6x6)
CASE(TextureFormat, RGBA_ASTC_8x5)
CASE(TextureFormat, RGBA_ASTC_8x6)
CASE(TextureFormat, RGBA_ASTC_8x8)
CASE(TextureFormat, RGBA_ASTC_10x5)
CASE(TextureFormat, RGBA_ASTC_10x6)
CASE(TextureFormat, RGBA_ASTC_10x8)
CASE(TextureFormat, RGBA_ASTC_10x10)
CASE(TextureFormat, RGBA_ASTC_12x10)
CASE(TextureFormat, RGBA_ASTC_12x12)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_4x4)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_5x4)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_5x5)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_6x5)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_6x6)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_8x5)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_8x6)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_8x8)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_10x5)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_10x6)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_10x8)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_10x10)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_12x10)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_12x12)
}
return out;
}
io::ostream& operator<<(io::ostream& out, TextureUsage usage) {
switch (usage) {
CASE(TextureUsage, NONE)
CASE(TextureUsage, DEFAULT)
CASE(TextureUsage, COLOR_ATTACHMENT)
CASE(TextureUsage, DEPTH_ATTACHMENT)
CASE(TextureUsage, STENCIL_ATTACHMENT)
CASE(TextureUsage, UPLOADABLE)
CASE(TextureUsage, SAMPLEABLE)
CASE(TextureUsage, SUBPASS_INPUT)
}
return out;
}
io::ostream& operator<<(io::ostream& out, TextureCubemapFace face) {
switch (face) {
CASE(TextureCubemapFace, NEGATIVE_X)
CASE(TextureCubemapFace, POSITIVE_X)
CASE(TextureCubemapFace, NEGATIVE_Y)
CASE(TextureCubemapFace, POSITIVE_Y)
CASE(TextureCubemapFace, NEGATIVE_Z)
CASE(TextureCubemapFace, POSITIVE_Z)
}
return out;
}
io::ostream& operator<<(io::ostream& out, SamplerWrapMode wrap) {
switch (wrap) {
CASE(SamplerWrapMode, REPEAT)
CASE(SamplerWrapMode, CLAMP_TO_EDGE)
CASE(SamplerWrapMode, MIRRORED_REPEAT)
}
return out;
}
io::ostream& operator<<(io::ostream& out, SamplerMinFilter filter) {
switch (filter) {
CASE(SamplerMinFilter, NEAREST)
CASE(SamplerMinFilter, LINEAR)
CASE(SamplerMinFilter, NEAREST_MIPMAP_NEAREST)
CASE(SamplerMinFilter, LINEAR_MIPMAP_NEAREST)
CASE(SamplerMinFilter, NEAREST_MIPMAP_LINEAR)
CASE(SamplerMinFilter, LINEAR_MIPMAP_LINEAR)
}
return out;
}
io::ostream& operator<<(io::ostream& out, SamplerMagFilter filter) {
switch (filter) {
CASE(SamplerMagFilter, NEAREST)
CASE(SamplerMagFilter, LINEAR)
}
return out;
}
io::ostream& operator<<(io::ostream& out, SamplerCompareMode mode) {
switch (mode) {
CASE(SamplerCompareMode, NONE)
CASE(SamplerCompareMode, COMPARE_TO_TEXTURE)
}
return out;
}
io::ostream& operator<<(io::ostream& out, SamplerCompareFunc func) {
switch (func) {
CASE(SamplerCompareFunc, LE)
CASE(SamplerCompareFunc, GE)
CASE(SamplerCompareFunc, L)
CASE(SamplerCompareFunc, G)
CASE(SamplerCompareFunc, E)
CASE(SamplerCompareFunc, NE)
CASE(SamplerCompareFunc, A)
CASE(SamplerCompareFunc, N)
}
return out;
}
io::ostream& operator<<(io::ostream& out, BufferObjectBinding binding) {
switch (binding) {
CASE(BufferObjectBinding, VERTEX)
}
return out;
}
io::ostream& operator<<(io::ostream& out, TextureSwizzle swizzle) {
switch (swizzle) {
CASE(TextureSwizzle, SUBSTITUTE_ZERO)
CASE(TextureSwizzle, SUBSTITUTE_ONE)
CASE(TextureSwizzle, CHANNEL_0)
CASE(TextureSwizzle, CHANNEL_1)
CASE(TextureSwizzle, CHANNEL_2)
CASE(TextureSwizzle, CHANNEL_3)
}
return out;
}
io::ostream& operator<<(io::ostream& out, SamplerParams params) {
out << "SamplerParams{ "
<< params.filterMin << ", "
<< params.filterMag << ", "
<< params.wrapS << ", "
<< params.wrapT << ", "
<< params.wrapR << ", "
<< (1u << params.anisotropyLog2) << ", "
<< params.compareMode << ", "
<< params.compareFunc
<< " }";
return out;
}
io::ostream& operator<<(io::ostream& out, const AttributeArray& type) {
return out << "AttributeArray[" << type.max_size() << "]{}";
}
io::ostream& operator<<(io::ostream& out, const FaceOffsets& type) {
return out << "FaceOffsets{"
<< type[0] << ", "
<< type[1] << ", "
<< type[2] << ", "
<< type[3] << ", "
<< type[4] << ", "
<< type[5] << "}";
}
io::ostream& operator<<(io::ostream& out, const RasterState& rs) {
// TODO: implement decoding of enums
return out << "RasterState{"
<< rs.culling << ", "
<< uint8_t(rs.blendEquationRGB) << ", "
<< uint8_t(rs.blendEquationAlpha) << ", "
<< uint8_t(rs.blendFunctionSrcRGB) << ", "
<< uint8_t(rs.blendFunctionSrcAlpha) << ", "
<< uint8_t(rs.blendFunctionDstRGB) << ", "
<< uint8_t(rs.blendFunctionDstAlpha) << "}";
}
io::ostream& operator<<(io::ostream& out, const TargetBufferInfo& tbi) {
return out << "TargetBufferInfo{"
<< "h=" << tbi.handle << ", "
<< "level=" << tbi.level << ", "
<< "face=" << tbi.face << "}";
}
io::ostream& operator<<(io::ostream& out, const PolygonOffset& po) {
return out << "PolygonOffset{"
<< "slope=" << po.slope << ", "
<< "constant=" << po.constant << "}";
}
io::ostream& operator<<(io::ostream& out, const PipelineState& ps) {
return out << "PipelineState{"
<< "program=" << ps.program << ", "
<< "rasterState=" << ps.rasterState << ", "
<< "polygonOffset=" << ps.polygonOffset << "}";
}
UTILS_PRIVATE
io::ostream& operator<<(io::ostream& out, BufferDescriptor const& b) {
out << "BufferDescriptor { buffer=" << b.buffer
<< ", size=" << b.size
<< ", callback=" << b.getCallback()
<< ", user=" << b.getUser() << " }";
return out;
}
UTILS_PRIVATE
io::ostream& operator<<(io::ostream& out, PixelBufferDescriptor const& b) {
BufferDescriptor const& base = static_cast<BufferDescriptor const&>(b);
out << "PixelBufferDescriptor { " << base
<< ", left=" << b.left
<< ", top=" << b.top
<< ", stride=" << b.stride
<< ", format=" << b.format
<< ", type=" << b.type
<< ", alignment=" << b.alignment << " }";
return out;
}
UTILS_PRIVATE
io::ostream& operator<<(io::ostream& out, filament::backend::Viewport const& viewport) {
out << "Viewport{"
<< ", left=" << viewport.left
<< ", bottom=" << viewport.bottom
<< ", width=" << viewport.width
<< ", height=" << viewport.height << "}";
return out;
}
UTILS_PRIVATE
io::ostream& operator<<(io::ostream& out, TargetBufferFlags flags) {
// TODO: implement decoding of enum
out << uint8_t(flags);
return out;
}
UTILS_PRIVATE
io::ostream& operator<<(io::ostream& out, RenderPassParams const& params) {
out << "RenderPassParams{"
<< "clear=" << params.flags.clear
<< ", discardStart=" << params.flags.discardStart
<< ", discardEnd=" << params.flags.discardEnd
<< ", left=" << params.viewport.left
<< ", bottom=" << params.viewport.bottom
<< ", width=" << params.viewport.width
<< ", height=" << params.viewport.height
<< ", clearColor=" << params.clearColor
<< ", clearDepth=" << params.clearDepth
<< ", clearStencil=" << params.clearStencil << "}";
return out;
}
UTILS_PRIVATE
io::ostream& operator<<(io::ostream& out, MRT const& mrt) {
// TODO: implement decoding of enum
out << "MRT{...}";
return out;
}
#undef CASE
#endif // !NDEBUG
+500
View File
@@ -0,0 +1,500 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <backend/BufferDescriptor.h>
#include <backend/DriverEnums.h>
#include <backend/PipelineState.h>
#include <backend/PixelBufferDescriptor.h>
#include <backend/TargetBufferInfo.h>
#include <utils/ostream.h>
using namespace filament;
using namespace backend;
using namespace utils;
// ------------------------------------------------------------------------------------------------
// Stream operators for all types in DriverEnums.h
// (These must live outside of the filament namespace)
// ------------------------------------------------------------------------------------------------
#if !defined(NDEBUG)
#define CASE(ENUM, VALUE) \
case ENUM::VALUE: { \
out << #VALUE; \
break; \
}
io::ostream& operator<<(io::ostream& out, ShaderModel model) {
switch (model) {
CASE(ShaderModel, UNKNOWN)
CASE(ShaderModel, GL_ES_30)
CASE(ShaderModel, GL_CORE_41)
}
return out;
}
io::ostream& operator<<(io::ostream& out, PrimitiveType type) {
switch (type) {
CASE(PrimitiveType, TRIANGLES)
CASE(PrimitiveType, LINES)
CASE(PrimitiveType, POINTS)
CASE(PrimitiveType, NONE)
}
return out;
}
io::ostream& operator<<(io::ostream& out, ElementType type) {
switch (type) {
CASE(ElementType, BYTE)
CASE(ElementType, BYTE2)
CASE(ElementType, BYTE3)
CASE(ElementType, BYTE4)
CASE(ElementType, UBYTE)
CASE(ElementType, UBYTE2)
CASE(ElementType, UBYTE3)
CASE(ElementType, UBYTE4)
CASE(ElementType, SHORT)
CASE(ElementType, SHORT2)
CASE(ElementType, SHORT3)
CASE(ElementType, SHORT4)
CASE(ElementType, USHORT)
CASE(ElementType, USHORT2)
CASE(ElementType, USHORT3)
CASE(ElementType, USHORT4)
CASE(ElementType, INT)
CASE(ElementType, UINT)
CASE(ElementType, FLOAT)
CASE(ElementType, FLOAT2)
CASE(ElementType, FLOAT3)
CASE(ElementType, FLOAT4)
CASE(ElementType, HALF)
CASE(ElementType, HALF2)
CASE(ElementType, HALF3)
CASE(ElementType, HALF4)
}
return out;
}
io::ostream& operator<<(io::ostream& out, BufferUsage usage) {
switch (usage) {
CASE(BufferUsage, STATIC)
CASE(BufferUsage, DYNAMIC)
CASE(BufferUsage, STREAM)
}
return out;
}
io::ostream& operator<<(io::ostream& out, CullingMode mode) {
switch (mode) {
CASE(CullingMode, NONE)
CASE(CullingMode, FRONT)
CASE(CullingMode, BACK)
CASE(CullingMode, FRONT_AND_BACK)
}
return out;
}
io::ostream& operator<<(io::ostream& out, SamplerType type) {
switch (type) {
CASE(SamplerType, SAMPLER_2D)
CASE(SamplerType, SAMPLER_2D_ARRAY)
CASE(SamplerType, SAMPLER_3D)
CASE(SamplerType, SAMPLER_CUBEMAP)
CASE(SamplerType, SAMPLER_EXTERNAL)
}
return out;
}
io::ostream& operator<<(io::ostream& out, SamplerFormat type) {
switch (type) {
CASE(SamplerFormat, INT)
CASE(SamplerFormat, UINT)
CASE(SamplerFormat, FLOAT)
CASE(SamplerFormat, SHADOW)
}
return out;
}
io::ostream& operator<<(io::ostream& out, Precision precision) {
switch (precision) {
CASE(Precision, LOW)
CASE(Precision, MEDIUM)
CASE(Precision, HIGH)
CASE(Precision, DEFAULT)
}
return out;
}
io::ostream& operator<<(io::ostream& out, PixelDataFormat format) {
switch (format) {
CASE(PixelDataFormat, R)
CASE(PixelDataFormat, R_INTEGER)
CASE(PixelDataFormat, RG)
CASE(PixelDataFormat, RG_INTEGER)
CASE(PixelDataFormat, RGB)
CASE(PixelDataFormat, RGB_INTEGER)
CASE(PixelDataFormat, RGBA)
CASE(PixelDataFormat, RGBA_INTEGER)
CASE(PixelDataFormat, DEPTH_COMPONENT)
CASE(PixelDataFormat, DEPTH_STENCIL)
CASE(PixelDataFormat, ALPHA)
CASE(PixelDataFormat, UNUSED)
}
return out;
}
io::ostream& operator<<(io::ostream& out, PixelDataType format) {
switch (format) {
CASE(PixelDataType, UBYTE)
CASE(PixelDataType, BYTE)
CASE(PixelDataType, USHORT)
CASE(PixelDataType, SHORT)
CASE(PixelDataType, UINT)
CASE(PixelDataType, INT)
CASE(PixelDataType, HALF)
CASE(PixelDataType, FLOAT)
CASE(PixelDataType, COMPRESSED)
CASE(PixelDataType, UINT_10F_11F_11F_REV)
CASE(PixelDataType, USHORT_565)
CASE(PixelDataType, UINT_2_10_10_10_REV)
}
return out;
}
io::ostream& operator<<(io::ostream& out, TextureFormat format) {
switch (format) {
CASE(TextureFormat, R8)
CASE(TextureFormat, R8_SNORM)
CASE(TextureFormat, R16F)
CASE(TextureFormat, R32F)
CASE(TextureFormat, R8UI)
CASE(TextureFormat, R8I)
CASE(TextureFormat, STENCIL8)
CASE(TextureFormat, R16UI)
CASE(TextureFormat, R16I)
CASE(TextureFormat, R32UI)
CASE(TextureFormat, R32I)
CASE(TextureFormat, RG8)
CASE(TextureFormat, RG8_SNORM)
CASE(TextureFormat, RG16F)
CASE(TextureFormat, RG32F)
CASE(TextureFormat, RG8UI)
CASE(TextureFormat, RG8I)
CASE(TextureFormat, RG16UI)
CASE(TextureFormat, RG16I)
CASE(TextureFormat, RG32UI)
CASE(TextureFormat, RG32I)
CASE(TextureFormat, RGB8)
CASE(TextureFormat, SRGB8)
CASE(TextureFormat, RGB565)
CASE(TextureFormat, RGB8_SNORM)
CASE(TextureFormat, R11F_G11F_B10F)
CASE(TextureFormat, RGB9_E5)
CASE(TextureFormat, RGB16F)
CASE(TextureFormat, RGB32F)
CASE(TextureFormat, RGB8UI)
CASE(TextureFormat, RGB8I)
CASE(TextureFormat, RGB16UI)
CASE(TextureFormat, RGB16I)
CASE(TextureFormat, RGB32UI)
CASE(TextureFormat, RGB32I)
CASE(TextureFormat, RGBA8)
CASE(TextureFormat, SRGB8_A8)
CASE(TextureFormat, RGBA8_SNORM)
CASE(TextureFormat, RGB5_A1)
CASE(TextureFormat, RGBA4)
CASE(TextureFormat, RGB10_A2)
CASE(TextureFormat, RGBA16F)
CASE(TextureFormat, RGBA32F)
CASE(TextureFormat, RGBA8UI)
CASE(TextureFormat, RGBA8I)
CASE(TextureFormat, RGBA16UI)
CASE(TextureFormat, RGBA16I)
CASE(TextureFormat, RGBA32UI)
CASE(TextureFormat, RGBA32I)
CASE(TextureFormat, DEPTH16)
CASE(TextureFormat, DEPTH24)
CASE(TextureFormat, DEPTH32F)
CASE(TextureFormat, DEPTH24_STENCIL8)
CASE(TextureFormat, DEPTH32F_STENCIL8)
// compressed formats...
CASE(TextureFormat, EAC_R11)
CASE(TextureFormat, EAC_R11_SIGNED)
CASE(TextureFormat, EAC_RG11)
CASE(TextureFormat, EAC_RG11_SIGNED)
CASE(TextureFormat, ETC2_RGB8)
CASE(TextureFormat, ETC2_SRGB8)
CASE(TextureFormat, ETC2_RGB8_A1)
CASE(TextureFormat, ETC2_SRGB8_A1)
CASE(TextureFormat, ETC2_EAC_RGBA8)
CASE(TextureFormat, ETC2_EAC_SRGBA8)
CASE(TextureFormat, DXT1_RGB)
CASE(TextureFormat, DXT1_SRGB)
CASE(TextureFormat, DXT1_RGBA)
CASE(TextureFormat, DXT1_SRGBA)
CASE(TextureFormat, DXT3_RGBA)
CASE(TextureFormat, DXT3_SRGBA)
CASE(TextureFormat, DXT5_RGBA)
CASE(TextureFormat, DXT5_SRGBA)
CASE(TextureFormat, UNUSED)
CASE(TextureFormat, RGBA_ASTC_4x4)
CASE(TextureFormat, RGBA_ASTC_5x4)
CASE(TextureFormat, RGBA_ASTC_5x5)
CASE(TextureFormat, RGBA_ASTC_6x5)
CASE(TextureFormat, RGBA_ASTC_6x6)
CASE(TextureFormat, RGBA_ASTC_8x5)
CASE(TextureFormat, RGBA_ASTC_8x6)
CASE(TextureFormat, RGBA_ASTC_8x8)
CASE(TextureFormat, RGBA_ASTC_10x5)
CASE(TextureFormat, RGBA_ASTC_10x6)
CASE(TextureFormat, RGBA_ASTC_10x8)
CASE(TextureFormat, RGBA_ASTC_10x10)
CASE(TextureFormat, RGBA_ASTC_12x10)
CASE(TextureFormat, RGBA_ASTC_12x12)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_4x4)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_5x4)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_5x5)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_6x5)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_6x6)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_8x5)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_8x6)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_8x8)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_10x5)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_10x6)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_10x8)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_10x10)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_12x10)
CASE(TextureFormat, SRGB8_ALPHA8_ASTC_12x12)
}
return out;
}
io::ostream& operator<<(io::ostream& out, TextureUsage usage) {
switch (usage) {
CASE(TextureUsage, NONE)
CASE(TextureUsage, DEFAULT)
CASE(TextureUsage, COLOR_ATTACHMENT)
CASE(TextureUsage, DEPTH_ATTACHMENT)
CASE(TextureUsage, STENCIL_ATTACHMENT)
CASE(TextureUsage, UPLOADABLE)
CASE(TextureUsage, SAMPLEABLE)
CASE(TextureUsage, SUBPASS_INPUT)
}
return out;
}
io::ostream& operator<<(io::ostream& out, TextureCubemapFace face) {
switch (face) {
CASE(TextureCubemapFace, NEGATIVE_X)
CASE(TextureCubemapFace, POSITIVE_X)
CASE(TextureCubemapFace, NEGATIVE_Y)
CASE(TextureCubemapFace, POSITIVE_Y)
CASE(TextureCubemapFace, NEGATIVE_Z)
CASE(TextureCubemapFace, POSITIVE_Z)
}
return out;
}
io::ostream& operator<<(io::ostream& out, SamplerWrapMode wrap) {
switch (wrap) {
CASE(SamplerWrapMode, REPEAT)
CASE(SamplerWrapMode, CLAMP_TO_EDGE)
CASE(SamplerWrapMode, MIRRORED_REPEAT)
}
return out;
}
io::ostream& operator<<(io::ostream& out, SamplerMinFilter filter) {
switch (filter) {
CASE(SamplerMinFilter, NEAREST)
CASE(SamplerMinFilter, LINEAR)
CASE(SamplerMinFilter, NEAREST_MIPMAP_NEAREST)
CASE(SamplerMinFilter, LINEAR_MIPMAP_NEAREST)
CASE(SamplerMinFilter, NEAREST_MIPMAP_LINEAR)
CASE(SamplerMinFilter, LINEAR_MIPMAP_LINEAR)
}
return out;
}
io::ostream& operator<<(io::ostream& out, SamplerMagFilter filter) {
switch (filter) {
CASE(SamplerMagFilter, NEAREST)
CASE(SamplerMagFilter, LINEAR)
}
return out;
}
io::ostream& operator<<(io::ostream& out, SamplerCompareMode mode) {
switch (mode) {
CASE(SamplerCompareMode, NONE)
CASE(SamplerCompareMode, COMPARE_TO_TEXTURE)
}
return out;
}
io::ostream& operator<<(io::ostream& out, SamplerCompareFunc func) {
switch (func) {
CASE(SamplerCompareFunc, LE)
CASE(SamplerCompareFunc, GE)
CASE(SamplerCompareFunc, L)
CASE(SamplerCompareFunc, G)
CASE(SamplerCompareFunc, E)
CASE(SamplerCompareFunc, NE)
CASE(SamplerCompareFunc, A)
CASE(SamplerCompareFunc, N)
}
return out;
}
io::ostream& operator<<(io::ostream& out, BufferObjectBinding binding) {
switch (binding) {
CASE(BufferObjectBinding, VERTEX)
CASE(BufferObjectBinding, UNIFORM)
}
return out;
}
io::ostream& operator<<(io::ostream& out, TextureSwizzle swizzle) {
switch (swizzle) {
CASE(TextureSwizzle, SUBSTITUTE_ZERO)
CASE(TextureSwizzle, SUBSTITUTE_ONE)
CASE(TextureSwizzle, CHANNEL_0)
CASE(TextureSwizzle, CHANNEL_1)
CASE(TextureSwizzle, CHANNEL_2)
CASE(TextureSwizzle, CHANNEL_3)
}
return out;
}
io::ostream& operator<<(io::ostream& out, SamplerParams params) {
out << "SamplerParams{ "
<< params.filterMin << ", "
<< params.filterMag << ", "
<< params.wrapS << ", "
<< params.wrapT << ", "
<< params.wrapR << ", "
<< (1u << params.anisotropyLog2) << ", "
<< params.compareMode << ", "
<< params.compareFunc
<< " }";
return out;
}
io::ostream& operator<<(io::ostream& out, const AttributeArray& type) {
return out << "AttributeArray[" << type.max_size() << "]{}";
}
io::ostream& operator<<(io::ostream& out, const FaceOffsets& type) {
return out << "FaceOffsets{"
<< type[0] << ", "
<< type[1] << ", "
<< type[2] << ", "
<< type[3] << ", "
<< type[4] << ", "
<< type[5] << "}";
}
io::ostream& operator<<(io::ostream& out, const RasterState& rs) {
// TODO: implement decoding of enums
return out << "RasterState{"
<< rs.culling << ", "
<< uint8_t(rs.blendEquationRGB) << ", "
<< uint8_t(rs.blendEquationAlpha) << ", "
<< uint8_t(rs.blendFunctionSrcRGB) << ", "
<< uint8_t(rs.blendFunctionSrcAlpha) << ", "
<< uint8_t(rs.blendFunctionDstRGB) << ", "
<< uint8_t(rs.blendFunctionDstAlpha) << "}";
}
io::ostream& operator<<(io::ostream& out, const TargetBufferInfo& tbi) {
return out << "TargetBufferInfo{"
<< "h=" << tbi.handle
<< ", level=" << tbi.level
<< ", face=" << tbi.face << "}";
}
io::ostream& operator<<(io::ostream& out, const PolygonOffset& po) {
return out << "PolygonOffset{"
<< "slope=" << po.slope
<< ", constant=" << po.constant << "}";
}
io::ostream& operator<<(io::ostream& out, const PipelineState& ps) {
return out << "PipelineState{"
<< "program=" << ps.program
<< ", rasterState=" << ps.rasterState
<< ", polygonOffset=" << ps.polygonOffset << "}";
}
io::ostream& operator<<(io::ostream& out, BufferDescriptor const& b) {
return out << "BufferDescriptor{ buffer=" << b.buffer
<< ", size=" << b.size
<< ", callback=" << b.getCallback()
<< ", user=" << b.getUser() << " }";
}
io::ostream& operator<<(io::ostream& out, PixelBufferDescriptor const& b) {
BufferDescriptor const& base = static_cast<BufferDescriptor const&>(b);
return out << "PixelBufferDescriptor{ " << base
<< "left=" << b.left
<< ", top=" << b.top
<< ", stride=" << b.stride
<< ", format=" << b.format
<< ", type=" << b.type
<< ", alignment=" << b.alignment << " }";
}
io::ostream& operator<<(io::ostream& out, filament::backend::Viewport const& viewport) {
return out << "Viewport{"
<< "left=" << viewport.left
<< ", bottom=" << viewport.bottom
<< ", width=" << viewport.width
<< ", height=" << viewport.height << "}";
}
io::ostream& operator<<(io::ostream& out, TargetBufferFlags flags) {
// TODO: implement decoding of enum
out << uint8_t(flags);
return out;
}
io::ostream& operator<<(io::ostream& out, RenderPassParams const& params) {
out << "RenderPassParams{"
<< "clear=" << params.flags.clear
<< ", discardStart=" << params.flags.discardStart
<< ", discardEnd=" << params.flags.discardEnd
<< ", left=" << params.viewport.left
<< ", bottom=" << params.viewport.bottom
<< ", width=" << params.viewport.width
<< ", height=" << params.viewport.height
<< ", clearColor=" << params.clearColor
<< ", clearDepth=" << params.clearDepth
<< ", clearStencil=" << params.clearStencil << "}";
return out;
}
io::ostream& operator<<(io::ostream& out, MRT const& mrt) {
// TODO: implement decoding of enum
out << "MRT{...}";
return out;
}
#undef CASE
#endif // !NDEBUG