Commit e4477001 by Corentin Wallez Committed by Commit Bot

Add PackedEnumBitSet, use it for buffer binding validation

Includes angle::BitSetT changes from jmadill@chromium.org BUG=angleproject:2169 Change-Id: I9f896613f5c6cdc91281cb9a00134f67291870d9 Reviewed-on: https://chromium-review.googlesource.com/804177Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
parent 4fba4a97
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
namespace angle namespace angle
{ {
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT = std::size_t>
class BitSetT final class BitSetT final
{ {
public: public:
...@@ -73,10 +73,10 @@ class BitSetT final ...@@ -73,10 +73,10 @@ class BitSetT final
bool operator==(const BitSetT &other) const; bool operator==(const BitSetT &other) const;
bool operator!=(const BitSetT &other) const; bool operator!=(const BitSetT &other) const;
constexpr bool operator[](std::size_t pos) const; constexpr bool operator[](ParamT pos) const;
Reference operator[](std::size_t pos) { return Reference(this, pos); } Reference operator[](ParamT pos) { return Reference(this, pos); }
bool test(std::size_t pos) const; bool test(ParamT pos) const;
bool all() const; bool all() const;
bool any() const; bool any() const;
...@@ -96,13 +96,13 @@ class BitSetT final ...@@ -96,13 +96,13 @@ class BitSetT final
BitSetT &operator>>=(std::size_t pos); BitSetT &operator>>=(std::size_t pos);
BitSetT &set(); BitSetT &set();
BitSetT &set(std::size_t pos, bool value = true); BitSetT &set(ParamT pos, bool value = true);
BitSetT &reset(); BitSetT &reset();
BitSetT &reset(std::size_t pos); BitSetT &reset(ParamT pos);
BitSetT &flip(); BitSetT &flip();
BitSetT &flip(std::size_t pos); BitSetT &flip(ParamT pos);
unsigned long to_ulong() const { return static_cast<unsigned long>(mBits); } unsigned long to_ulong() const { return static_cast<unsigned long>(mBits); }
BitsT bits() const { return mBits; } BitsT bits() const { return mBits; }
...@@ -111,7 +111,10 @@ class BitSetT final ...@@ -111,7 +111,10 @@ class BitSetT final
Iterator end() const { return Iterator(BitSetT()); } Iterator end() const { return Iterator(BitSetT()); }
private: private:
constexpr static BitsT Bit(std::size_t x) { return (static_cast<BitsT>(1) << x); } constexpr static BitsT Bit(ParamT x)
{
return (static_cast<BitsT>(1) << static_cast<size_t>(x));
}
constexpr static BitsT Mask(std::size_t x) { return ((Bit(x - 1) - 1) << 1) + 1; } constexpr static BitsT Mask(std::size_t x) { return ((Bit(x - 1) - 1) << 1) + 1; }
BitsT mBits; BitsT mBits;
...@@ -202,148 +205,148 @@ unsigned long IterableBitSet<N>::Iterator::getNextBit() ...@@ -202,148 +205,148 @@ unsigned long IterableBitSet<N>::Iterator::getNextBit()
return 0; return 0;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT>::BitSetT() : mBits(0) BitSetT<N, BitsT, ParamT>::BitSetT() : mBits(0)
{ {
static_assert(N > 0, "Bitset type cannot support zero bits."); static_assert(N > 0, "Bitset type cannot support zero bits.");
static_assert(N <= sizeof(BitsT) * 8, "Bitset type cannot support a size this large."); static_assert(N <= sizeof(BitsT) * 8, "Bitset type cannot support a size this large.");
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT>::BitSetT(BitsT value) : mBits(value & Mask(N)) BitSetT<N, BitsT, ParamT>::BitSetT(BitsT value) : mBits(value & Mask(N))
{ {
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT>::~BitSetT() BitSetT<N, BitsT, ParamT>::~BitSetT()
{ {
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT>::BitSetT(const BitSetT &other) : mBits(other.mBits) BitSetT<N, BitsT, ParamT>::BitSetT(const BitSetT &other) : mBits(other.mBits)
{ {
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT> &BitSetT<N, BitsT>::operator=(const BitSetT &other) BitSetT<N, BitsT, ParamT> &BitSetT<N, BitsT, ParamT>::operator=(const BitSetT &other)
{ {
mBits = other.mBits; mBits = other.mBits;
return *this; return *this;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
bool BitSetT<N, BitsT>::operator==(const BitSetT &other) const bool BitSetT<N, BitsT, ParamT>::operator==(const BitSetT &other) const
{ {
return mBits == other.mBits; return mBits == other.mBits;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
bool BitSetT<N, BitsT>::operator!=(const BitSetT &other) const bool BitSetT<N, BitsT, ParamT>::operator!=(const BitSetT &other) const
{ {
return mBits != other.mBits; return mBits != other.mBits;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
constexpr bool BitSetT<N, BitsT>::operator[](std::size_t pos) const constexpr bool BitSetT<N, BitsT, ParamT>::operator[](ParamT pos) const
{ {
return test(pos); return test(pos);
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
bool BitSetT<N, BitsT>::test(std::size_t pos) const bool BitSetT<N, BitsT, ParamT>::test(ParamT pos) const
{ {
return (mBits & Bit(pos)) != 0; return (mBits & Bit(pos)) != 0;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
bool BitSetT<N, BitsT>::all() const bool BitSetT<N, BitsT, ParamT>::all() const
{ {
ASSERT(mBits == (mBits & Mask(N))); ASSERT(mBits == (mBits & Mask(N)));
return mBits == Mask(N); return mBits == Mask(N);
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
bool BitSetT<N, BitsT>::any() const bool BitSetT<N, BitsT, ParamT>::any() const
{ {
ASSERT(mBits == (mBits & Mask(N))); ASSERT(mBits == (mBits & Mask(N)));
return (mBits != 0); return (mBits != 0);
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
bool BitSetT<N, BitsT>::none() const bool BitSetT<N, BitsT, ParamT>::none() const
{ {
ASSERT(mBits == (mBits & Mask(N))); ASSERT(mBits == (mBits & Mask(N)));
return (mBits == 0); return (mBits == 0);
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
std::size_t BitSetT<N, BitsT>::count() const std::size_t BitSetT<N, BitsT, ParamT>::count() const
{ {
return gl::BitCount(mBits); return gl::BitCount(mBits);
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT> &BitSetT<N, BitsT>::operator&=(const BitSetT &other) BitSetT<N, BitsT, ParamT> &BitSetT<N, BitsT, ParamT>::operator&=(const BitSetT &other)
{ {
mBits &= other.mBits; mBits &= other.mBits;
return *this; return *this;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT> &BitSetT<N, BitsT>::operator|=(const BitSetT &other) BitSetT<N, BitsT, ParamT> &BitSetT<N, BitsT, ParamT>::operator|=(const BitSetT &other)
{ {
mBits |= other.mBits; mBits |= other.mBits;
return *this; return *this;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT> &BitSetT<N, BitsT>::operator^=(const BitSetT &other) BitSetT<N, BitsT, ParamT> &BitSetT<N, BitsT, ParamT>::operator^=(const BitSetT &other)
{ {
mBits = (mBits ^ other.mBits) & Mask(N); mBits = (mBits ^ other.mBits) & Mask(N);
return *this; return *this;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT> BitSetT<N, BitsT>::operator~() const BitSetT<N, BitsT, ParamT> BitSetT<N, BitsT, ParamT>::operator~() const
{ {
return BitSetT<N, BitsT>(~mBits & Mask(N)); return BitSetT<N, BitsT, ParamT>(~mBits & Mask(N));
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT> BitSetT<N, BitsT>::operator<<(std::size_t pos) const BitSetT<N, BitsT, ParamT> BitSetT<N, BitsT, ParamT>::operator<<(std::size_t pos) const
{ {
return BitSetT<N, BitsT>((mBits << pos) & Mask(N)); return BitSetT<N, BitsT, ParamT>((mBits << pos) & Mask(N));
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT> &BitSetT<N, BitsT>::operator<<=(std::size_t pos) BitSetT<N, BitsT, ParamT> &BitSetT<N, BitsT, ParamT>::operator<<=(std::size_t pos)
{ {
mBits = (mBits << pos & Mask(N)); mBits = (mBits << pos & Mask(N));
return *this; return *this;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT> BitSetT<N, BitsT>::operator>>(std::size_t pos) const BitSetT<N, BitsT, ParamT> BitSetT<N, BitsT, ParamT>::operator>>(std::size_t pos) const
{ {
return BitSetT<N, BitsT>(mBits >> pos); return BitSetT<N, BitsT, ParamT>(mBits >> pos);
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT> &BitSetT<N, BitsT>::operator>>=(std::size_t pos) BitSetT<N, BitsT, ParamT> &BitSetT<N, BitsT, ParamT>::operator>>=(std::size_t pos)
{ {
mBits = ((mBits >> pos) & Mask(N)); mBits = ((mBits >> pos) & Mask(N));
return *this; return *this;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT> &BitSetT<N, BitsT>::set() BitSetT<N, BitsT, ParamT> &BitSetT<N, BitsT, ParamT>::set()
{ {
mBits = Mask(N); mBits = Mask(N);
return *this; return *this;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT> &BitSetT<N, BitsT>::set(std::size_t pos, bool value) BitSetT<N, BitsT, ParamT> &BitSetT<N, BitsT, ParamT>::set(ParamT pos, bool value)
{ {
if (value) if (value)
{ {
...@@ -356,36 +359,36 @@ BitSetT<N, BitsT> &BitSetT<N, BitsT>::set(std::size_t pos, bool value) ...@@ -356,36 +359,36 @@ BitSetT<N, BitsT> &BitSetT<N, BitsT>::set(std::size_t pos, bool value)
return *this; return *this;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT> &BitSetT<N, BitsT>::reset() BitSetT<N, BitsT, ParamT> &BitSetT<N, BitsT, ParamT>::reset()
{ {
mBits = 0; mBits = 0;
return *this; return *this;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT> &BitSetT<N, BitsT>::reset(std::size_t pos) BitSetT<N, BitsT, ParamT> &BitSetT<N, BitsT, ParamT>::reset(ParamT pos)
{ {
mBits &= ~Bit(pos); mBits &= ~Bit(pos);
return *this; return *this;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT> &BitSetT<N, BitsT>::flip() BitSetT<N, BitsT, ParamT> &BitSetT<N, BitsT, ParamT>::flip()
{ {
mBits ^= Mask(N); mBits ^= Mask(N);
return *this; return *this;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT> &BitSetT<N, BitsT>::flip(std::size_t pos) BitSetT<N, BitsT, ParamT> &BitSetT<N, BitsT, ParamT>::flip(ParamT pos)
{ {
mBits ^= Bit(pos); mBits ^= Bit(pos);
return *this; return *this;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
BitSetT<N, BitsT>::Iterator::Iterator(const BitSetT &bits) : mBitsCopy(bits), mCurrentBit(0) BitSetT<N, BitsT, ParamT>::Iterator::Iterator(const BitSetT &bits) : mBitsCopy(bits), mCurrentBit(0)
{ {
if (bits.any()) if (bits.any())
{ {
...@@ -393,8 +396,8 @@ BitSetT<N, BitsT>::Iterator::Iterator(const BitSetT &bits) : mBitsCopy(bits), mC ...@@ -393,8 +396,8 @@ BitSetT<N, BitsT>::Iterator::Iterator(const BitSetT &bits) : mBitsCopy(bits), mC
} }
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
typename BitSetT<N, BitsT>::Iterator &BitSetT<N, BitsT>::Iterator::operator++() typename BitSetT<N, BitsT, ParamT>::Iterator &BitSetT<N, BitsT, ParamT>::Iterator::operator++()
{ {
ASSERT(mBitsCopy.any()); ASSERT(mBitsCopy.any());
mBitsCopy.reset(mCurrentBit); mBitsCopy.reset(mCurrentBit);
...@@ -402,26 +405,26 @@ typename BitSetT<N, BitsT>::Iterator &BitSetT<N, BitsT>::Iterator::operator++() ...@@ -402,26 +405,26 @@ typename BitSetT<N, BitsT>::Iterator &BitSetT<N, BitsT>::Iterator::operator++()
return *this; return *this;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
bool BitSetT<N, BitsT>::Iterator::operator==(const Iterator &other) const bool BitSetT<N, BitsT, ParamT>::Iterator::operator==(const Iterator &other) const
{ {
return mBitsCopy == other.mBitsCopy; return mBitsCopy == other.mBitsCopy;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
bool BitSetT<N, BitsT>::Iterator::operator!=(const Iterator &other) const bool BitSetT<N, BitsT, ParamT>::Iterator::operator!=(const Iterator &other) const
{ {
return !(*this == other); return !(*this == other);
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
std::size_t BitSetT<N, BitsT>::Iterator::operator*() const std::size_t BitSetT<N, BitsT, ParamT>::Iterator::operator*() const
{ {
return mCurrentBit; return mCurrentBit;
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
std::size_t BitSetT<N, BitsT>::Iterator::getNextBit() std::size_t BitSetT<N, BitsT, ParamT>::Iterator::getNextBit()
{ {
if (mBitsCopy.none()) if (mBitsCopy.none())
{ {
...@@ -474,25 +477,25 @@ using BitSet = typename priv::GetBitSet<N>::Type; ...@@ -474,25 +477,25 @@ using BitSet = typename priv::GetBitSet<N>::Type;
} // angle } // angle
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
inline angle::BitSetT<N, BitsT> operator&(const angle::BitSetT<N, BitsT> &lhs, inline angle::BitSetT<N, BitsT, ParamT> operator&(const angle::BitSetT<N, BitsT, ParamT> &lhs,
const angle::BitSetT<N, BitsT> &rhs) const angle::BitSetT<N, BitsT, ParamT> &rhs)
{ {
return angle::BitSetT<N, BitsT>(lhs.bits() & rhs.bits()); return angle::BitSetT<N, BitsT, ParamT>(lhs.bits() & rhs.bits());
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
inline angle::BitSetT<N, BitsT> operator|(const angle::BitSetT<N, BitsT> &lhs, inline angle::BitSetT<N, BitsT, ParamT> operator|(const angle::BitSetT<N, BitsT, ParamT> &lhs,
const angle::BitSetT<N, BitsT> &rhs) const angle::BitSetT<N, BitsT, ParamT> &rhs)
{ {
return angle::BitSetT<N, BitsT>(lhs.bits() | rhs.bits()); return angle::BitSetT<N, BitsT, ParamT>(lhs.bits() | rhs.bits());
} }
template <size_t N, typename BitsT> template <size_t N, typename BitsT, typename ParamT>
inline angle::BitSetT<N, BitsT> operator^(const angle::BitSetT<N, BitsT> &lhs, inline angle::BitSetT<N, BitsT, ParamT> operator^(const angle::BitSetT<N, BitsT, ParamT> &lhs,
const angle::BitSetT<N, BitsT> &rhs) const angle::BitSetT<N, BitsT, ParamT> &rhs)
{ {
return angle::BitSetT<N, BitsT>(lhs.bits() ^ rhs.bits()); return angle::BitSetT<N, BitsT, ParamT>(lhs.bits() ^ rhs.bits());
} }
#endif // COMMON_BITSETITERATOR_H_ #endif // COMMON_BITSETITERATOR_H_
...@@ -2780,6 +2780,33 @@ void Context::updateCaps() ...@@ -2780,6 +2780,33 @@ void Context::updateCaps()
{ {
mMemoryProgramCache = nullptr; mMemoryProgramCache = nullptr;
} }
// Compute which buffer types are allowed
mValidBufferBindings.reset();
mValidBufferBindings.set(BufferBinding::ElementArray);
mValidBufferBindings.set(BufferBinding::Array);
if (mExtensions.pixelBufferObject || getClientVersion() >= ES_3_0)
{
mValidBufferBindings.set(BufferBinding::PixelPack);
mValidBufferBindings.set(BufferBinding::PixelUnpack);
}
if (getClientVersion() >= ES_3_0)
{
mValidBufferBindings.set(BufferBinding::CopyRead);
mValidBufferBindings.set(BufferBinding::CopyWrite);
mValidBufferBindings.set(BufferBinding::TransformFeedback);
mValidBufferBindings.set(BufferBinding::Uniform);
}
if (getClientVersion() >= ES_3_1)
{
mValidBufferBindings.set(BufferBinding::AtomicCounter);
mValidBufferBindings.set(BufferBinding::ShaderStorage);
mValidBufferBindings.set(BufferBinding::DrawIndirect);
mValidBufferBindings.set(BufferBinding::DispatchIndirect);
}
} }
void Context::initWorkarounds() void Context::initWorkarounds()
......
...@@ -140,11 +140,16 @@ class ValidationContext : angle::NonCopyable ...@@ -140,11 +140,16 @@ class ValidationContext : angle::NonCopyable
template <typename T> template <typename T>
const T &getParams() const; const T &getParams() const;
bool isValidBufferBinding(BufferBinding binding) const { return mValidBufferBindings[binding]; }
protected: protected:
ContextState mState; ContextState mState;
bool mSkipValidation; bool mSkipValidation;
bool mDisplayTextureShareGroup; bool mDisplayTextureShareGroup;
// Stores for each buffer binding type whether is it allowed to be used in this context.
angle::PackedEnumBitSet<BufferBinding> mValidBufferBindings;
// Caches entry point parameters and values re-used between layers. // Caches entry point parameters and values re-used between layers.
mutable const ParamTypeInfo *mSavedArgsType; mutable const ParamTypeInfo *mSavedArgsType;
static constexpr size_t kParamsBufferSize = 64u; static constexpr size_t kParamsBufferSize = 64u;
......
...@@ -12,11 +12,28 @@ ...@@ -12,11 +12,28 @@
#include "libANGLE/PackedGLEnums_autogen.h" #include "libANGLE/PackedGLEnums_autogen.h"
#include <array> #include <array>
#include <bitset>
#include <cstddef> #include <cstddef>
#include "common/bitset_utils.h"
namespace angle namespace angle
{ {
// Return the number of elements of a packed enum, including the InvalidEnum element.
template <typename E>
constexpr size_t EnumSize()
{
using UnderlyingType = typename std::underlying_type<E>::type;
return static_cast<UnderlyingType>(E::EnumCount);
}
// Implementation of AllEnums which allows iterating over all the possible values for a packed enums
// like so:
// for (auto value : AllEnums<MyPackedEnum>()) {
// // Do something with the enum.
// }
template <typename E> template <typename E>
class EnumIterator final class EnumIterator final
{ {
...@@ -45,13 +62,14 @@ struct AllEnums ...@@ -45,13 +62,14 @@ struct AllEnums
EnumIterator<E> end() const { return {E::InvalidEnum}; } EnumIterator<E> end() const { return {E::InvalidEnum}; }
}; };
// PackedEnumMap<E, T> is like an std::array<T, E::EnumCount> but is indexed with enum values. It
// implements all of the std::array interface except with enum values instead of indices.
template <typename E, typename T> template <typename E, typename T>
class PackedEnumMap class PackedEnumMap
{ {
private: private:
using UnderlyingType = typename std::underlying_type<E>::type; using UnderlyingType = typename std::underlying_type<E>::type;
static constexpr size_t kSize = static_cast<UnderlyingType>(E::EnumCount); using Storage = std::array<T, EnumSize<E>()>;
using Storage = std::array<T, kSize>;
Storage mData; Storage mData;
...@@ -106,6 +124,11 @@ class PackedEnumMap ...@@ -106,6 +124,11 @@ class PackedEnumMap
const T *data() const noexcept { return mData.data(); } const T *data() const noexcept { return mData.data(); }
}; };
// PackedEnumBitSetE> is like an std::bitset<E::EnumCount> but is indexed with enum values. It
// implements the std::bitset interface except with enum values instead of indices.
template <typename E>
using PackedEnumBitSet = BitSetT<EnumSize<E>(), uint32_t, E>;
} // namespace angle } // namespace angle
#endif // LIBANGLE_PACKEDGLENUMS_H_ #endif // LIBANGLE_PACKEDGLENUMS_H_
...@@ -649,36 +649,6 @@ bool ValidFramebufferTarget(const ValidationContext *context, GLenum target) ...@@ -649,36 +649,6 @@ bool ValidFramebufferTarget(const ValidationContext *context, GLenum target)
} }
} }
bool ValidBufferType(const ValidationContext *context, BufferBinding target)
{
switch (target)
{
case BufferBinding::ElementArray:
case BufferBinding::Array:
return true;
case BufferBinding::PixelPack:
case BufferBinding::PixelUnpack:
return (context->getExtensions().pixelBufferObject ||
context->getClientMajorVersion() >= 3);
case BufferBinding::CopyRead:
case BufferBinding::CopyWrite:
case BufferBinding::TransformFeedback:
case BufferBinding::Uniform:
return (context->getClientMajorVersion() >= 3);
case BufferBinding::AtomicCounter:
case BufferBinding::ShaderStorage:
case BufferBinding::DrawIndirect:
case BufferBinding::DispatchIndirect:
return context->getClientVersion() >= Version(3, 1);
default:
return false;
}
}
bool ValidMipLevel(const ValidationContext *context, GLenum target, GLint level) bool ValidMipLevel(const ValidationContext *context, GLenum target, GLint level)
{ {
const auto &caps = context->getCaps(); const auto &caps = context->getCaps();
...@@ -3497,7 +3467,7 @@ bool ValidateGetBufferPointervBase(Context *context, ...@@ -3497,7 +3467,7 @@ bool ValidateGetBufferPointervBase(Context *context,
return false; return false;
} }
if (!ValidBufferType(context, target)) if (!context->isValidBufferBinding(target))
{ {
context->handleError(InvalidEnum() << "Buffer target not valid"); context->handleError(InvalidEnum() << "Buffer target not valid");
return false; return false;
...@@ -3533,7 +3503,7 @@ bool ValidateGetBufferPointervBase(Context *context, ...@@ -3533,7 +3503,7 @@ bool ValidateGetBufferPointervBase(Context *context,
bool ValidateUnmapBufferBase(Context *context, BufferBinding target) bool ValidateUnmapBufferBase(Context *context, BufferBinding target)
{ {
if (!ValidBufferType(context, target)) if (!context->isValidBufferBinding(target))
{ {
ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes);
return false; return false;
...@@ -3556,7 +3526,7 @@ bool ValidateMapBufferRangeBase(Context *context, ...@@ -3556,7 +3526,7 @@ bool ValidateMapBufferRangeBase(Context *context,
GLsizeiptr length, GLsizeiptr length,
GLbitfield access) GLbitfield access)
{ {
if (!ValidBufferType(context, target)) if (!context->isValidBufferBinding(target))
{ {
ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes);
return false; return false;
...@@ -3663,7 +3633,7 @@ bool ValidateFlushMappedBufferRangeBase(Context *context, ...@@ -3663,7 +3633,7 @@ bool ValidateFlushMappedBufferRangeBase(Context *context,
return false; return false;
} }
if (!ValidBufferType(context, target)) if (!context->isValidBufferBinding(target))
{ {
ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes);
return false; return false;
...@@ -4704,7 +4674,7 @@ bool ValidateGetBufferParameterBase(ValidationContext *context, ...@@ -4704,7 +4674,7 @@ bool ValidateGetBufferParameterBase(ValidationContext *context,
*numParams = 0; *numParams = 0;
} }
if (!ValidBufferType(context, target)) if (!context->isValidBufferBinding(target))
{ {
ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes);
return false; return false;
......
...@@ -39,7 +39,6 @@ bool ValidTexture2DDestinationTarget(const ValidationContext *context, GLenum ta ...@@ -39,7 +39,6 @@ bool ValidTexture2DDestinationTarget(const ValidationContext *context, GLenum ta
bool ValidTexture3DDestinationTarget(const ValidationContext *context, GLenum target); bool ValidTexture3DDestinationTarget(const ValidationContext *context, GLenum target);
bool ValidTexLevelDestinationTarget(const ValidationContext *context, GLenum target); bool ValidTexLevelDestinationTarget(const ValidationContext *context, GLenum target);
bool ValidFramebufferTarget(const ValidationContext *context, GLenum target); bool ValidFramebufferTarget(const ValidationContext *context, GLenum target);
bool ValidBufferType(const ValidationContext *context, BufferBinding target);
bool ValidBufferParameter(const ValidationContext *context, GLenum pname, GLsizei *numParams); bool ValidBufferParameter(const ValidationContext *context, GLenum pname, GLsizei *numParams);
bool ValidMipLevel(const ValidationContext *context, GLenum target, GLint level); bool ValidMipLevel(const ValidationContext *context, GLenum target, GLint level);
bool ValidImageSizeParameters(ValidationContext *context, bool ValidImageSizeParameters(ValidationContext *context,
......
...@@ -2838,7 +2838,7 @@ bool ValidateMapBufferOES(Context *context, BufferBinding target, GLenum access) ...@@ -2838,7 +2838,7 @@ bool ValidateMapBufferOES(Context *context, BufferBinding target, GLenum access)
return false; return false;
} }
if (!ValidBufferType(context, target)) if (!context->isValidBufferBinding(target))
{ {
ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes);
return false; return false;
...@@ -4206,7 +4206,7 @@ bool ValidateBufferData(ValidationContext *context, ...@@ -4206,7 +4206,7 @@ bool ValidateBufferData(ValidationContext *context,
return false; return false;
} }
if (!ValidBufferType(context, target)) if (!context->isValidBufferBinding(target))
{ {
ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes);
return false; return false;
...@@ -4241,7 +4241,7 @@ bool ValidateBufferSubData(ValidationContext *context, ...@@ -4241,7 +4241,7 @@ bool ValidateBufferSubData(ValidationContext *context,
return false; return false;
} }
if (!ValidBufferType(context, target)) if (!context->isValidBufferBinding(target))
{ {
ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes);
return false; return false;
...@@ -4408,7 +4408,7 @@ bool ValidateBindAttribLocation(ValidationContext *context, ...@@ -4408,7 +4408,7 @@ bool ValidateBindAttribLocation(ValidationContext *context,
bool ValidateBindBuffer(ValidationContext *context, BufferBinding target, GLuint buffer) bool ValidateBindBuffer(ValidationContext *context, BufferBinding target, GLuint buffer)
{ {
if (!ValidBufferType(context, target)) if (!context->isValidBufferBinding(target))
{ {
ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes); ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes);
return false; return false;
......
...@@ -2466,7 +2466,7 @@ bool ValidateCopyBufferSubData(ValidationContext *context, ...@@ -2466,7 +2466,7 @@ bool ValidateCopyBufferSubData(ValidationContext *context,
return false; return false;
} }
if (!ValidBufferType(context, readTarget) || !ValidBufferType(context, writeTarget)) if (!context->isValidBufferBinding(readTarget) || !context->isValidBufferBinding(writeTarget))
{ {
context->handleError(InvalidEnum() << "Invalid buffer target"); context->handleError(InvalidEnum() << "Invalid buffer target");
return false; return false;
......
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