Commit 97035bde by Ben Clayton

Switch SIMD::Pointer::base from a Float* to Byte*

While having the base units as sizeof(float) is handy (as that's the smallest unit we currently support), it makes limit checking tricky as we're continually converting units of byte <-> float. This sets us up nicely for when we want to support smaller types. Change-Id: I3e334b6df4899f433b281118be23fdf8df6d9829 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/29328 Presubmit-Ready: Ben Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 5f7e9117
......@@ -71,9 +71,9 @@ namespace sw
inline void addOffset(Int delta) { offset += delta; uniform = false; }
// Base address for the pointer, common across all lanes.
rr::Pointer<rr::Float> base;
rr::Pointer<rr::Byte> base;
// Per lane offsets from base.
// Per lane offsets from base in bytes.
// If uniform is true, all offsets are considered zero.
Int offset;
......@@ -624,6 +624,8 @@ namespace sw
SIMD::Pointer WalkExplicitLayoutAccessChain(Object::ID id, uint32_t numIndexes, uint32_t const *indexIds, SpirvRoutine *routine) const;
SIMD::Pointer WalkAccessChain(Object::ID id, uint32_t numIndexes, uint32_t const *indexIds, SpirvRoutine *routine) const;
// Returns the *component* offset in the literal for the given access chain.
uint32_t WalkLiteralAccessChain(Type::ID id, uint32_t numIndexes, uint32_t const *indexes) const;
// EmitState holds control-flow state for the emit() pass.
......
......@@ -2349,11 +2349,30 @@ namespace rr
}
template<typename T>
RValue<T> Load(Pointer<T> pointer, unsigned int alignment, bool atomic, std::memory_order memoryOrder)
{
return Load(RValue<Pointer<T>>(pointer), alignment, atomic, memoryOrder);
}
template<typename T>
void Store(RValue<T> value, RValue<Pointer<T>> pointer, unsigned int alignment, bool atomic, std::memory_order memoryOrder)
{
Nucleus::createStore(value.value, pointer.value, T::getType(), false, alignment, atomic, memoryOrder);
}
template<typename T>
void Store(RValue<T> value, Pointer<T> pointer, unsigned int alignment, bool atomic, std::memory_order memoryOrder)
{
Store(value, RValue<Pointer<T>>(pointer), alignment, atomic, memoryOrder);
}
template<typename T>
void Store(T value, Pointer<T> pointer, unsigned int alignment, bool atomic, std::memory_order memoryOrder)
{
Store(RValue<T>(value), RValue<Pointer<T>>(pointer), alignment, atomic, memoryOrder);
}
template<class T, int S = 1>
class Array : public LValue<T>
{
......
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