void SpirvShader::ProcessInterfaceVariable(Object &object)
{
auto &objectTy = getType(object.type);
- assert(objectTy.storageClass == spv::StorageClassInput || objectTy.storageClass == spv::StorageClassOutput);
+ ASSERT(objectTy.storageClass == spv::StorageClassInput || objectTy.storageClass == spv::StorageClassOutput);
- assert(objectTy.definition.opcode() == spv::OpTypePointer);
+ ASSERT(objectTy.definition.opcode() == spv::OpTypePointer);
auto pointeeTy = getType(objectTy.element);
auto &builtinInterface = (objectTy.storageClass == spv::StorageClassInput) ? inputBuiltins : outputBuiltins;
auto &userDefinedInterface = (objectTy.storageClass == spv::StorageClassInput) ? inputs : outputs;
- assert(object.definition.opcode() == spv::OpVariable);
+ ASSERT(object.definition.opcode() == spv::OpVariable);
ObjectID resultId = object.definition.word(2);
if (objectTy.isBuiltInBlock)
{
// walk the builtin block, registering each of its members separately.
auto m = memberDecorations.find(objectTy.element);
- assert(m != memberDecorations.end()); // otherwise we wouldn't have marked the type chain
+ ASSERT(m != memberDecorations.end()); // otherwise we wouldn't have marked the type chain
auto &structType = pointeeTy.definition;
auto offset = 0u;
auto word = 2u;
[&userDefinedInterface](Decorations const &d, AttribType type) {
// Populate a single scalar slot in the interface from a collection of decorations and the intended component type.
auto scalarSlot = (d.Location << 2) | d.Component;
- assert(scalarSlot >= 0 &&
+ ASSERT(scalarSlot >= 0 &&
scalarSlot < static_cast<int32_t>(userDefinedInterface.size()));
auto &slot = userDefinedInterface[scalarSlot];
ApplyDecorationsForId(&d, id);
auto def = getObject(id).definition;
- assert(def.opcode() == spv::OpVariable);
+ ASSERT(def.opcode() == spv::OpVariable);
VisitInterfaceInner<F>(def.word(1), d, f);
}
// TODO: not encountered yet since we only use this for array sizes etc,
// but is possible to construct integer constant 0 via OpConstantNull.
auto insn = getObject(id).definition;
- assert(insn.opcode() == spv::OpConstant);
- assert(getType(insn.word(1)).definition.opcode() == spv::OpTypeInt);
+ ASSERT(insn.opcode() == spv::OpConstant);
+ ASSERT(getType(insn.word(1)).definition.opcode() == spv::OpTypeInt);
return insn.word(3);
}
#include "ShaderCore.hpp"
#include "SpirvID.hpp"
+#include <cstring>
#include <string>
#include <vector>
#include <unordered_map>
public:
using Scalar = RValue<SIMD::Float>;
- Intermediate(uint32_t size) : contents(new ContentsType[size]), size(size) {}
+ Intermediate(uint32_t size) : contents(new ContentsType[size]), size(size) {
+#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
+ memset(contents, 0, sizeof(ContentsType[size]));
+#endif
+ }
~Intermediate()
{
void emplace(uint32_t n, Scalar&& value)
{
- assert(n < size);
+ ASSERT(n < size);
+ ASSERT(reinterpret_cast<Scalar const *>(&contents[n])->value == nullptr);
new (&contents[n]) Scalar(value);
}
void emplace(uint32_t n, const Scalar& value)
{
- assert(n < size);
+ ASSERT(n < size);
+ ASSERT(reinterpret_cast<Scalar const *>(&contents[n])->value == nullptr);
new (&contents[n]) Scalar(value);
}
Scalar const & operator[](uint32_t n) const
{
- assert(n < size);
- return *reinterpret_cast<Scalar const *>(&contents[n]);
+ ASSERT(n < size);
+ auto scalar = reinterpret_cast<Scalar const *>(&contents[n]);
+ ASSERT(scalar->value != nullptr);
+ return *scalar;
}
// No copy/move construction or assignment
Type const &getType(TypeID id) const
{
auto it = types.find(id);
- assert(it != types.end());
+ ASSERT(it != types.end());
return it->second;
}
Object const &getObject(ObjectID id) const
{
auto it = defs.find(id);
- assert(it != defs.end());
+ ASSERT(it != defs.end());
return it->second;
}
Value& getValue(SpirvShader::ObjectID id)
{
auto it = lvalues.find(id);
- assert(it != lvalues.end());
+ ASSERT(it != lvalues.end());
return it->second;
}
Intermediate const& getIntermediate(SpirvShader::ObjectID id) const
{
auto it = intermediates.find(id);
- assert(it != intermediates.end());
+ ASSERT(it != intermediates.end());
return it->second;
}
};