|
|
@@ -1,10 +1,6 @@
|
|
|
#pragma once
|
|
|
|
|
|
#include "BsCorePrerequisites.h"
|
|
|
-#include "BsGpuParamDesc.h"
|
|
|
-#include "BsGpuParamBlockBuffer.h"
|
|
|
-#include "BsDebug.h"
|
|
|
-#include "BsException.h"
|
|
|
#include "BsVector2.h"
|
|
|
#include "BsVector3.h"
|
|
|
#include "BsVector4.h"
|
|
|
@@ -14,222 +10,10 @@
|
|
|
|
|
|
namespace BansheeEngine
|
|
|
{
|
|
|
- /**
|
|
|
- * @brief Base class containing some non-templated methods for
|
|
|
- * all types for GpuParams
|
|
|
- */
|
|
|
- class BS_CORE_EXPORT GpuParamBase
|
|
|
- {
|
|
|
- protected:
|
|
|
- GpuParamBase();
|
|
|
- GpuParamBase(const SPtr<GpuParams>& parent);
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Marks the core data as dirty, signifying the core thread it should update it.
|
|
|
- */
|
|
|
- void markCoreDirty();
|
|
|
-
|
|
|
- protected:
|
|
|
- SPtr<GpuParams> mParent;
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Base class containing some non-templated methods for
|
|
|
- * GpuDataParam.
|
|
|
- *
|
|
|
- * @see TGpuDataParam
|
|
|
- */
|
|
|
- class BS_CORE_EXPORT GpuDataParamBase : public GpuParamBase
|
|
|
- {
|
|
|
- protected:
|
|
|
- GpuDataParamBase();
|
|
|
- GpuDataParamBase(GpuParamDataDesc* paramDesc, const SPtr<GpuParams>& parent);
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns true if matrices need to be transposed when reading/writing them.
|
|
|
- */
|
|
|
- bool getTransposeMatrices() const;
|
|
|
-
|
|
|
- /**
|
|
|
- * @copydoc GpuParamBlockBuffer::write
|
|
|
- */
|
|
|
- bool write(UINT32 offset, const void* data, UINT32 size);
|
|
|
-
|
|
|
- /**
|
|
|
- * @copydoc GpuParamBlockBuffer::read
|
|
|
- */
|
|
|
- bool read(UINT32 offset, void* data, UINT32 size);
|
|
|
-
|
|
|
- /**
|
|
|
- * @copydoc GpuParamBlockBuffer::zeroOut
|
|
|
- */
|
|
|
- void zeroOut(UINT32 offset, UINT32 size);
|
|
|
-
|
|
|
- protected:
|
|
|
- GpuParamDataDesc* mParamDesc;
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Base class containing some non-templated methods for
|
|
|
- * GpuObjectParam.
|
|
|
- *
|
|
|
- * @see TGpuObjectParam
|
|
|
- */
|
|
|
- class BS_CORE_EXPORT GpuObjectParamBase : public GpuParamBase
|
|
|
- {
|
|
|
- protected:
|
|
|
- GpuObjectParamBase();
|
|
|
- GpuObjectParamBase(GpuParamObjectDesc* paramDesc, const SPtr<GpuParams>& parent);
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Gets a texture bound to the specified slot.
|
|
|
- */
|
|
|
- HTexture getTexture(UINT32 slot);
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Gets a sampler state bound to the specified slot.
|
|
|
- */
|
|
|
- HSamplerState getSamplerState(UINT32 slot);
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Sets a texture at the specified slot.
|
|
|
- */
|
|
|
- void setTexture(UINT32 slot, const HTexture& texture);
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Sets a sampler state at the specified slot.
|
|
|
- */
|
|
|
- void setSamplerState(UINT32 slot, const HSamplerState& sampler);
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Sets information that determines which texture surfaces to bind
|
|
|
- * as load/store parameters.
|
|
|
- */
|
|
|
- void setLoadStoreSurface(UINT32 slot, const TextureSurface& surface) const;
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Changes the type of the texture at the specified slot.
|
|
|
- */
|
|
|
- void setIsLoadStoreTexture(UINT32 slot, bool isLoadStore);
|
|
|
-
|
|
|
- protected:
|
|
|
- GpuParamObjectDesc* mParamDesc;
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Base class containing some non-templated methods for
|
|
|
- * all types for GpuParamCore params
|
|
|
- */
|
|
|
- class BS_CORE_EXPORT GpuParamCoreBase
|
|
|
- {
|
|
|
- protected:
|
|
|
- GpuParamCoreBase();
|
|
|
- GpuParamCoreBase(const SPtr<GpuParamsCore>& parent);
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Marks the core data as dirty, signifying the core thread it should update it.
|
|
|
- */
|
|
|
- void markCoreDirty();
|
|
|
-
|
|
|
- protected:
|
|
|
- SPtr<GpuParamsCore> mParent;
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Base class containing some non-templated methods for
|
|
|
- * GpuDataParam.
|
|
|
- *
|
|
|
- * @see TGpuDataParam
|
|
|
- */
|
|
|
- class BS_CORE_EXPORT GpuDataParamCoreBase : public GpuParamCoreBase
|
|
|
- {
|
|
|
- protected:
|
|
|
- GpuDataParamCoreBase();
|
|
|
- GpuDataParamCoreBase(GpuParamDataDesc* paramDesc, const SPtr<GpuParamsCore>& parent);
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Returns true if matrices need to be transposed when reading/writing them.
|
|
|
- */
|
|
|
- bool getTransposeMatrices() const;
|
|
|
-
|
|
|
- /**
|
|
|
- * @copydoc GpuParamBlockBuffer::write
|
|
|
- */
|
|
|
- bool write(UINT32 offset, const void* data, UINT32 size);
|
|
|
-
|
|
|
- /**
|
|
|
- * @copydoc GpuParamBlockBuffer::read
|
|
|
- */
|
|
|
- bool read(UINT32 offset, void* data, UINT32 size);
|
|
|
-
|
|
|
- /**
|
|
|
- * @copydoc GpuParamBlockBuffer::zeroOut
|
|
|
- */
|
|
|
- void zeroOut(UINT32 offset, UINT32 size);
|
|
|
-
|
|
|
- protected:
|
|
|
- GpuParamDataDesc* mParamDesc;
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Base class containing some non-templated methods for
|
|
|
- * GpuObjectParam.
|
|
|
- *
|
|
|
- * @see TGpuObjectParam
|
|
|
- */
|
|
|
- class BS_CORE_EXPORT GpuObjectParamCoreBase : public GpuParamCoreBase
|
|
|
- {
|
|
|
- protected:
|
|
|
- GpuObjectParamCoreBase();
|
|
|
- GpuObjectParamCoreBase(GpuParamObjectDesc* paramDesc, const SPtr<GpuParamsCore>& parent);
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Gets a texture bound to the specified slot.
|
|
|
- */
|
|
|
- SPtr<TextureCore> getTexture(UINT32 slot);
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Gets a sampler state bound to the specified slot.
|
|
|
- */
|
|
|
- SPtr<SamplerStateCore> getSamplerState(UINT32 slot);
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Sets a texture at the specified slot.
|
|
|
- */
|
|
|
- void setTexture(UINT32 slot, const SPtr<TextureCore>& texture);
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Sets a sampler state at the specified slot.
|
|
|
- */
|
|
|
- void setSamplerState(UINT32 slot, const SPtr<SamplerStateCore>& sampler);
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Sets information that determines which texture surfaces to bind
|
|
|
- * as load/store parameters.
|
|
|
- */
|
|
|
- void setLoadStoreSurface(UINT32 slot, const TextureSurface& surface) const;
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief Changes the type of the texture at the specified slot.
|
|
|
- */
|
|
|
- void setIsLoadStoreTexture(UINT32 slot, bool isLoadStore);
|
|
|
-
|
|
|
- protected:
|
|
|
- GpuParamObjectDesc* mParamDesc;
|
|
|
- };
|
|
|
-
|
|
|
template<bool Core> struct TGpuParamsPtrType { };
|
|
|
template<> struct TGpuParamsPtrType<false> { typedef SPtr<GpuParams> Type; };
|
|
|
template<> struct TGpuParamsPtrType<true> { typedef SPtr<GpuParamsCore> Type; };
|
|
|
|
|
|
- template<bool Core> struct TGpuDataParamBaseType { };
|
|
|
- template<> struct TGpuDataParamBaseType<false> { typedef GpuDataParamBase Type; };
|
|
|
- template<> struct TGpuDataParamBaseType<true> { typedef GpuDataParamCoreBase Type; };
|
|
|
-
|
|
|
- template<bool Core> struct TGpuObjectParamBaseType { };
|
|
|
- template<> struct TGpuObjectParamBaseType<false> { typedef GpuObjectParamBase Type; };
|
|
|
- template<> struct TGpuObjectParamBaseType<true> { typedef GpuObjectParamCoreBase Type; };
|
|
|
-
|
|
|
template<bool Core> struct TGpuParamTextureType { };
|
|
|
template<> struct TGpuParamTextureType < false > { typedef HTexture Type; };
|
|
|
template<> struct TGpuParamTextureType < true > { typedef SPtr<TextureCore> Type; };
|
|
|
@@ -256,9 +40,16 @@ namespace BansheeEngine
|
|
|
* @see Material
|
|
|
*/
|
|
|
template<class T, bool Core>
|
|
|
- class BS_CORE_EXPORT TGpuDataParam : public TGpuDataParamBaseType<Core>::Type
|
|
|
+ class BS_CORE_EXPORT TGpuDataParam
|
|
|
{
|
|
|
private:
|
|
|
+ template<bool Core> struct TGpuParamBufferType { };
|
|
|
+ template<> struct TGpuParamBufferType < false > { typedef SPtr<GpuParamBlockBuffer> Type; };
|
|
|
+ template<> struct TGpuParamBufferType < true > { typedef SPtr<GpuParamBlockBufferCore> Type; };
|
|
|
+
|
|
|
+ typedef typename TGpuParamBufferType<Core>::Type GpuParamBufferType;
|
|
|
+ typedef typename TGpuParamsPtrType<Core>::Type GpuParamsType;
|
|
|
+
|
|
|
/**
|
|
|
* @brief Policy class that allows us to re-use this template class for matrices which might
|
|
|
* need transposing, and other types which do not. Matrix needs to be transposed for
|
|
|
@@ -292,12 +83,8 @@ namespace BansheeEngine
|
|
|
};
|
|
|
|
|
|
public:
|
|
|
- TGpuDataParam()
|
|
|
- { }
|
|
|
-
|
|
|
- TGpuDataParam(GpuParamDataDesc* paramDesc, const typename TGpuParamsPtrType<Core>::Type& parent)
|
|
|
- :TGpuDataParamBaseType<Core>::Type(paramDesc, parent)
|
|
|
- { }
|
|
|
+ TGpuDataParam();
|
|
|
+ TGpuDataParam(GpuParamDataDesc* paramDesc, const GpuParamsType& parent);
|
|
|
|
|
|
/**
|
|
|
* @brief Sets a parameter value at the specified array index. If parameter does not
|
|
|
@@ -306,39 +93,7 @@ namespace BansheeEngine
|
|
|
* @note Like with all GPU parameters, the actual GPU buffer will not be updated until rendering
|
|
|
* with material this parameter was created from starts on the core thread.
|
|
|
*/
|
|
|
- void set(const T& value, UINT32 arrayIdx = 0)
|
|
|
- {
|
|
|
- if (mParent == nullptr)
|
|
|
- return;
|
|
|
-
|
|
|
-#if BS_DEBUG_MODE
|
|
|
- if (arrayIdx >= mParamDesc->arraySize)
|
|
|
- {
|
|
|
- BS_EXCEPT(InvalidParametersException, "Array index out of range. Array size: " +
|
|
|
- toString(mParamDesc->arraySize) + ". Requested size: " + toString(arrayIdx));
|
|
|
- }
|
|
|
-#endif
|
|
|
-
|
|
|
- UINT32 elementSizeBytes = mParamDesc->elementSize * sizeof(UINT32);
|
|
|
- UINT32 sizeBytes = std::min(elementSizeBytes, (UINT32)sizeof(T)); // Truncate if it doesn't fit within parameter size
|
|
|
-
|
|
|
- if (TransposePolicy<T>::transposeEnabled(getTransposeMatrices()))
|
|
|
- {
|
|
|
- T transposed = TransposePolicy<T>::transpose(value);
|
|
|
- write((mParamDesc->cpuMemOffset + arrayIdx * mParamDesc->arrayElementStride) * sizeof(UINT32), &transposed, sizeBytes);
|
|
|
- }
|
|
|
- else
|
|
|
- write((mParamDesc->cpuMemOffset + arrayIdx * mParamDesc->arrayElementStride) * sizeof(UINT32), &value, sizeBytes);
|
|
|
-
|
|
|
- // Set unused bytes to 0
|
|
|
- if(sizeBytes < elementSizeBytes)
|
|
|
- {
|
|
|
- UINT32 diffSize = elementSizeBytes - sizeBytes;
|
|
|
- zeroOut((mParamDesc->cpuMemOffset + arrayIdx * mParamDesc->arrayElementStride) * sizeof(UINT32)+sizeBytes, diffSize);
|
|
|
- }
|
|
|
-
|
|
|
- markCoreDirty();
|
|
|
- }
|
|
|
+ void set(const T& value, UINT32 arrayIdx = 0);
|
|
|
|
|
|
/**
|
|
|
* @brief Returns a value of a parameter at the specified array index. If parameter does not
|
|
|
@@ -346,310 +101,172 @@ namespace BansheeEngine
|
|
|
*
|
|
|
* @note No GPU reads are done. Data returned was cached when it was written.
|
|
|
*/
|
|
|
- T get(UINT32 arrayIdx = 0)
|
|
|
- {
|
|
|
- if (mParent == nullptr)
|
|
|
- return T();
|
|
|
-
|
|
|
-#if BS_DEBUG_MODE
|
|
|
- if (arrayIdx >= mParamDesc->arraySize)
|
|
|
- {
|
|
|
- BS_EXCEPT(InvalidParametersException, "Array index out of range. Array size: " +
|
|
|
- toString(mParamDesc->arraySize) + ". Requested size: " + toString(arrayIdx));
|
|
|
- }
|
|
|
-#endif
|
|
|
-
|
|
|
- UINT32 elementSizeBytes = mParamDesc->elementSize * sizeof(UINT32);
|
|
|
- UINT32 sizeBytes = std::min(elementSizeBytes, (UINT32)sizeof(T));
|
|
|
-
|
|
|
- T value;
|
|
|
- read((mParamDesc->cpuMemOffset + arrayIdx * mParamDesc->arrayElementStride) * sizeof(UINT32), &value, sizeBytes);
|
|
|
-
|
|
|
- if (TransposePolicy<T>::transposeEnabled(getTransposeMatrices()))
|
|
|
- return TransposePolicy<T>::transpose(value);
|
|
|
- else
|
|
|
- return value;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- typedef TGpuDataParam<float, false> GpuParamFloat;
|
|
|
- typedef TGpuDataParam<Color, false> GpuParamColor;
|
|
|
- typedef TGpuDataParam<Vector2, false> GpuParamVec2;
|
|
|
- typedef TGpuDataParam<Vector3, false> GpuParamVec3;
|
|
|
- typedef TGpuDataParam<Vector4, false> GpuParamVec4;
|
|
|
- typedef TGpuDataParam<Matrix3, false> GpuParamMat3;
|
|
|
- typedef TGpuDataParam<Matrix4, false> GpuParamMat4;
|
|
|
+ T get(UINT32 arrayIdx = 0);
|
|
|
|
|
|
- template class TGpuDataParam<float, false>;
|
|
|
- template class TGpuDataParam<Color, false>;
|
|
|
- template class TGpuDataParam<Vector2, false>;
|
|
|
- template class TGpuDataParam<Vector3, false>;
|
|
|
- template class TGpuDataParam<Vector4, false>;
|
|
|
- template class TGpuDataParam<Matrix3, false>;
|
|
|
- template class TGpuDataParam<Matrix4, false>;
|
|
|
-
|
|
|
- typedef TGpuDataParam<float, true> GpuParamFloatCore;
|
|
|
- typedef TGpuDataParam<Color, true> GpuParamColorCore;
|
|
|
- typedef TGpuDataParam<Vector2, true> GpuParamVec2Core;
|
|
|
- typedef TGpuDataParam<Vector3, true> GpuParamVec3Core;
|
|
|
- typedef TGpuDataParam<Vector4, true> GpuParamVec4Core;
|
|
|
- typedef TGpuDataParam<Matrix3, true> GpuParamMat3Core;
|
|
|
- typedef TGpuDataParam<Matrix4, true> GpuParamMat4Core;
|
|
|
-
|
|
|
- template class TGpuDataParam<float, true>;
|
|
|
- template class TGpuDataParam<Color, true>;
|
|
|
- template class TGpuDataParam<Vector2, true>;
|
|
|
- template class TGpuDataParam<Vector3, true>;
|
|
|
- template class TGpuDataParam<Vector4, true>;
|
|
|
- template class TGpuDataParam<Matrix3, true>;
|
|
|
- template class TGpuDataParam<Matrix4, true>;
|
|
|
+ protected:
|
|
|
+ GpuParamsType mParent;
|
|
|
+ GpuParamDataDesc* mParamDesc;
|
|
|
+ };
|
|
|
|
|
|
/**
|
|
|
* @copydoc TGpuDataParam
|
|
|
*/
|
|
|
template<bool Core>
|
|
|
- class BS_CORE_EXPORT TGpuParamStruct : public TGpuDataParamBaseType<Core>::Type
|
|
|
+ class BS_CORE_EXPORT TGpuParamStruct
|
|
|
{
|
|
|
public:
|
|
|
- TGpuParamStruct()
|
|
|
- { }
|
|
|
+ template<bool Core> struct TGpuParamBufferType { };
|
|
|
+ template<> struct TGpuParamBufferType < false > { typedef SPtr<GpuParamBlockBuffer> Type; };
|
|
|
+ template<> struct TGpuParamBufferType < true > { typedef SPtr<GpuParamBlockBufferCore> Type; };
|
|
|
|
|
|
- TGpuParamStruct(GpuParamDataDesc* paramDesc, const typename TGpuParamsPtrType<Core>::Type& parent)
|
|
|
- :TGpuDataParamBaseType<Core>::Type(paramDesc, parent)
|
|
|
- { }
|
|
|
+ typedef typename TGpuParamBufferType<Core>::Type GpuParamBufferType;
|
|
|
+ typedef typename TGpuParamsPtrType<Core>::Type GpuParamsType;
|
|
|
+
|
|
|
+ TGpuParamStruct();
|
|
|
+ TGpuParamStruct(GpuParamDataDesc* paramDesc, const GpuParamsType& parent);
|
|
|
|
|
|
/**
|
|
|
* @copydoc TGpuDataParam::set
|
|
|
*/
|
|
|
- void set(const void* value, UINT32 sizeBytes, UINT32 arrayIdx = 0)
|
|
|
- {
|
|
|
- if (mParent == nullptr)
|
|
|
- return;
|
|
|
-
|
|
|
- UINT32 elementSizeBytes = mParamDesc->elementSize * sizeof(UINT32);
|
|
|
-
|
|
|
-#if BS_DEBUG_MODE
|
|
|
- if (sizeBytes > elementSizeBytes)
|
|
|
- {
|
|
|
- LOGWRN("Provided element size larger than maximum element size. Maximum size: " +
|
|
|
- toString(elementSizeBytes) + ". Supplied size: " + toString(sizeBytes));
|
|
|
- }
|
|
|
-
|
|
|
- if (arrayIdx >= mParamDesc->arraySize)
|
|
|
- {
|
|
|
- BS_EXCEPT(InvalidParametersException, "Array index out of range. Array size: " +
|
|
|
- toString(mParamDesc->arraySize) + ". Requested size: " + toString(arrayIdx));
|
|
|
- }
|
|
|
-#endif
|
|
|
-
|
|
|
- sizeBytes = std::min(elementSizeBytes, sizeBytes);
|
|
|
-
|
|
|
- write((mParamDesc->cpuMemOffset + arrayIdx * mParamDesc->arrayElementStride) * sizeof(UINT32), value, sizeBytes);
|
|
|
-
|
|
|
- // Set unused bytes to 0
|
|
|
- if (sizeBytes < elementSizeBytes)
|
|
|
- {
|
|
|
- UINT32 diffSize = elementSizeBytes - sizeBytes;
|
|
|
- zeroOut((mParamDesc->cpuMemOffset + arrayIdx * mParamDesc->arrayElementStride) * sizeof(UINT32) + sizeBytes, diffSize);
|
|
|
- }
|
|
|
-
|
|
|
- markCoreDirty();
|
|
|
- }
|
|
|
+ void set(const void* value, UINT32 sizeBytes, UINT32 arrayIdx = 0);
|
|
|
|
|
|
/**
|
|
|
* @copydoc TGpuDataParam::get
|
|
|
*/
|
|
|
- void get(void* value, UINT32 sizeBytes, UINT32 arrayIdx = 0)
|
|
|
- {
|
|
|
- if (mParent == nullptr)
|
|
|
- return;
|
|
|
-
|
|
|
- UINT32 elementSizeBytes = mParamDesc->elementSize * sizeof(UINT32);
|
|
|
-
|
|
|
-#if BS_DEBUG_MODE
|
|
|
- if (sizeBytes > elementSizeBytes)
|
|
|
- {
|
|
|
- LOGWRN("Provided element size larger than maximum element size. Maximum size: " +
|
|
|
- toString(elementSizeBytes) + ". Supplied size: " + toString(sizeBytes));
|
|
|
- }
|
|
|
-
|
|
|
- if (arrayIdx >= mParamDesc->arraySize)
|
|
|
- {
|
|
|
- BS_EXCEPT(InvalidParametersException, "Array index out of range. Array size: " +
|
|
|
- toString(mParamDesc->arraySize) + ". Requested size: " + toString(arrayIdx));
|
|
|
- }
|
|
|
-#endif
|
|
|
- sizeBytes = std::min(elementSizeBytes, sizeBytes);
|
|
|
-
|
|
|
- read((mParamDesc->cpuMemOffset + arrayIdx * mParamDesc->arrayElementStride) * sizeof(UINT32), value, sizeBytes);
|
|
|
- }
|
|
|
+ void get(void* value, UINT32 sizeBytes, UINT32 arrayIdx = 0);
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @brief Returns the size of the struct in bytes.
|
|
|
*/
|
|
|
- UINT32 getElementSize() const
|
|
|
- {
|
|
|
- if (mParent == nullptr)
|
|
|
- return 0;
|
|
|
+ UINT32 getElementSize() const;
|
|
|
|
|
|
- return mParamDesc->elementSize * sizeof(UINT32);
|
|
|
- }
|
|
|
+ protected:
|
|
|
+ GpuParamsType mParent;
|
|
|
+ GpuParamDataDesc* mParamDesc;
|
|
|
};
|
|
|
|
|
|
- typedef TGpuParamStruct<false> GpuParamStruct;
|
|
|
- typedef TGpuParamStruct<true> GpuParamStructCore;
|
|
|
-
|
|
|
- template class TGpuParamStruct<false>;
|
|
|
- template class TGpuParamStruct<true>;
|
|
|
-
|
|
|
/**
|
|
|
* @copydoc TGpuObjectParam
|
|
|
*/
|
|
|
template<bool Core>
|
|
|
- class BS_CORE_EXPORT TGpuParamTexture : public TGpuObjectParamBaseType<Core>::Type
|
|
|
+ class BS_CORE_EXPORT TGpuParamTexture
|
|
|
{
|
|
|
private:
|
|
|
friend class GpuParams;
|
|
|
friend class GpuParamsCore;
|
|
|
|
|
|
- public:
|
|
|
- TGpuParamTexture()
|
|
|
- { }
|
|
|
+ typedef typename TGpuParamsPtrType<Core>::Type GpuParamsType;
|
|
|
+ typedef typename TGpuParamTextureType<Core>::Type TextureType;
|
|
|
|
|
|
- TGpuParamTexture(GpuParamObjectDesc* paramDesc, const typename TGpuParamsPtrType<Core>::Type& parent)
|
|
|
- :TGpuObjectParamBaseType<Core>::Type(paramDesc, parent)
|
|
|
- { }
|
|
|
+ public:
|
|
|
+ TGpuParamTexture();
|
|
|
+ TGpuParamTexture(GpuParamObjectDesc* paramDesc, const GpuParamsType& parent);
|
|
|
|
|
|
/**
|
|
|
* @copydoc TGpuDataParam::set
|
|
|
*/
|
|
|
- void set(const typename TGpuParamTextureType<Core>::Type& texture)
|
|
|
- {
|
|
|
- if (mParent == nullptr)
|
|
|
- return;
|
|
|
-
|
|
|
- setTexture(mParamDesc->slot, texture);
|
|
|
- setIsLoadStoreTexture(mParamDesc->slot, false);
|
|
|
-
|
|
|
- markCoreDirty();
|
|
|
- }
|
|
|
+ void set(const TextureType& texture);
|
|
|
|
|
|
/**
|
|
|
* @copydoc TGpuDataParam::get
|
|
|
*/
|
|
|
- typename TGpuParamTextureType<Core>::Type get()
|
|
|
- {
|
|
|
- if (mParent == nullptr)
|
|
|
- return TGpuParamTextureType<Core>::Type();
|
|
|
+ TextureType get();
|
|
|
|
|
|
- return getTexture(mParamDesc->slot);
|
|
|
- }
|
|
|
+ protected:
|
|
|
+ GpuParamsType mParent;
|
|
|
+ GpuParamObjectDesc* mParamDesc;
|
|
|
};
|
|
|
|
|
|
- typedef TGpuParamTexture<false> GpuParamTexture;
|
|
|
- typedef TGpuParamTexture<true> GpuParamTextureCore;
|
|
|
-
|
|
|
- template class TGpuParamTexture<false>;
|
|
|
- template class TGpuParamTexture<true>;
|
|
|
-
|
|
|
/**
|
|
|
* @copydoc TGpuObjectParam
|
|
|
*/
|
|
|
template<bool Core>
|
|
|
- class BS_CORE_EXPORT TGpuParamLoadStoreTexture : public TGpuObjectParamBaseType<Core>::Type
|
|
|
+ class BS_CORE_EXPORT TGpuParamLoadStoreTexture
|
|
|
{
|
|
|
private:
|
|
|
friend class GpuParams;
|
|
|
friend class GpuParamsCore;
|
|
|
|
|
|
- public:
|
|
|
- TGpuParamLoadStoreTexture()
|
|
|
- { }
|
|
|
+ typedef typename TGpuParamsPtrType<Core>::Type GpuParamsType;
|
|
|
+ typedef typename TGpuParamTextureType<Core>::Type TextureType;
|
|
|
|
|
|
- TGpuParamLoadStoreTexture(GpuParamObjectDesc* paramDesc, const typename TGpuParamsPtrType<Core>::Type& parent)
|
|
|
- :TGpuObjectParamBaseType<Core>::Type(paramDesc, parent)
|
|
|
- { }
|
|
|
+ public:
|
|
|
+ TGpuParamLoadStoreTexture();
|
|
|
+ TGpuParamLoadStoreTexture(GpuParamObjectDesc* paramDesc, const GpuParamsType& parent);
|
|
|
|
|
|
/**
|
|
|
* @copydoc TGpuDataParam::set
|
|
|
*/
|
|
|
- void set(const typename TGpuParamTextureType<Core>::Type& texture, const TextureSurface& surface)
|
|
|
- {
|
|
|
- if (mParent == nullptr)
|
|
|
- return;
|
|
|
-
|
|
|
- setTexture(mParamDesc->slot, texture);
|
|
|
- setIsLoadStoreTexture(mParamDesc->slot, true);
|
|
|
- setLoadStoreSurface(mParamDesc->slot, surface);
|
|
|
-
|
|
|
- markCoreDirty();
|
|
|
- }
|
|
|
+ void set(const TextureType& texture, const TextureSurface& surface);
|
|
|
|
|
|
/**
|
|
|
* @copydoc TGpuDataParam::get
|
|
|
*/
|
|
|
- typename TGpuParamTextureType<Core>::Type get()
|
|
|
- {
|
|
|
- if (mParent == nullptr)
|
|
|
- return TGpuParamTextureType<Core>::Type();
|
|
|
+ TextureType get();
|
|
|
|
|
|
- return getTexture(mParamDesc->slot);
|
|
|
- }
|
|
|
+ protected:
|
|
|
+ GpuParamsType mParent;
|
|
|
+ GpuParamObjectDesc* mParamDesc;
|
|
|
};
|
|
|
|
|
|
- typedef TGpuParamLoadStoreTexture<false> GpuParamLoadStoreTexture;
|
|
|
- typedef TGpuParamLoadStoreTexture<true> GpuParamLoadStoreTextureCore;
|
|
|
-
|
|
|
- template class TGpuParamLoadStoreTexture<false>;
|
|
|
- template class TGpuParamLoadStoreTexture<true>;
|
|
|
-
|
|
|
/**
|
|
|
* @copydoc TGpuObjectParam
|
|
|
*/
|
|
|
template<bool Core>
|
|
|
- class BS_CORE_EXPORT TGpuParamSampState : public TGpuObjectParamBaseType<Core>::Type
|
|
|
+ class BS_CORE_EXPORT TGpuParamSampState
|
|
|
{
|
|
|
private:
|
|
|
friend class GpuParams;
|
|
|
friend class GpuParamsCore;
|
|
|
|
|
|
- public:
|
|
|
- TGpuParamSampState()
|
|
|
- { }
|
|
|
+ typedef typename TGpuParamsPtrType<Core>::Type GpuParamsType;
|
|
|
+ typedef typename TGpuParamSamplerStateType<Core>::Type SamplerStateType;
|
|
|
|
|
|
- TGpuParamSampState(GpuParamObjectDesc* paramDesc, const typename TGpuParamsPtrType<Core>::Type& parent)
|
|
|
- :TGpuObjectParamBaseType<Core>::Type(paramDesc, parent)
|
|
|
- { }
|
|
|
+ public:
|
|
|
+ TGpuParamSampState();
|
|
|
+ TGpuParamSampState(GpuParamObjectDesc* paramDesc, const GpuParamsType& parent);
|
|
|
|
|
|
/**
|
|
|
* @copydoc TGpuDataParam::set
|
|
|
*/
|
|
|
- void set(const typename TGpuParamSamplerStateType<Core>::Type& samplerState)
|
|
|
- {
|
|
|
- if (mParent == nullptr)
|
|
|
- return;
|
|
|
-
|
|
|
- setSamplerState(mParamDesc->slot, samplerState);
|
|
|
-
|
|
|
- markCoreDirty();
|
|
|
- }
|
|
|
+ void set(const SamplerStateType& samplerState);
|
|
|
|
|
|
/**
|
|
|
* @copydoc TGpuDataParam::get
|
|
|
*/
|
|
|
- typename TGpuParamSamplerStateType<Core>::Type get()
|
|
|
- {
|
|
|
- if (mParent == nullptr)
|
|
|
- return TGpuParamSamplerStateType<Core>::Type();
|
|
|
+ SamplerStateType get();
|
|
|
|
|
|
- return getSamplerState(mParamDesc->slot);
|
|
|
- }
|
|
|
+ protected:
|
|
|
+ GpuParamsType mParent;
|
|
|
+ GpuParamObjectDesc* mParamDesc;
|
|
|
};
|
|
|
|
|
|
+ typedef TGpuDataParam<float, false> GpuParamFloat;
|
|
|
+ typedef TGpuDataParam<Color, false> GpuParamColor;
|
|
|
+ typedef TGpuDataParam<Vector2, false> GpuParamVec2;
|
|
|
+ typedef TGpuDataParam<Vector3, false> GpuParamVec3;
|
|
|
+ typedef TGpuDataParam<Vector4, false> GpuParamVec4;
|
|
|
+ typedef TGpuDataParam<Matrix3, false> GpuParamMat3;
|
|
|
+ typedef TGpuDataParam<Matrix4, false> GpuParamMat4;
|
|
|
+
|
|
|
+ typedef TGpuDataParam<float, true> GpuParamFloatCore;
|
|
|
+ typedef TGpuDataParam<Color, true> GpuParamColorCore;
|
|
|
+ typedef TGpuDataParam<Vector2, true> GpuParamVec2Core;
|
|
|
+ typedef TGpuDataParam<Vector3, true> GpuParamVec3Core;
|
|
|
+ typedef TGpuDataParam<Vector4, true> GpuParamVec4Core;
|
|
|
+ typedef TGpuDataParam<Matrix3, true> GpuParamMat3Core;
|
|
|
+ typedef TGpuDataParam<Matrix4, true> GpuParamMat4Core;
|
|
|
+
|
|
|
+ typedef TGpuParamStruct<false> GpuParamStruct;
|
|
|
+ typedef TGpuParamStruct<true> GpuParamStructCore;
|
|
|
+
|
|
|
+ typedef TGpuParamTexture<false> GpuParamTexture;
|
|
|
+ typedef TGpuParamTexture<true> GpuParamTextureCore;
|
|
|
+
|
|
|
typedef TGpuParamSampState<false> GpuParamSampState;
|
|
|
typedef TGpuParamSampState<true> GpuParamSampStateCore;
|
|
|
|
|
|
- template class TGpuParamSampState<false>;
|
|
|
- template class TGpuParamSampState<true>;
|
|
|
+ typedef TGpuParamLoadStoreTexture<false> GpuParamLoadStoreTexture;
|
|
|
+ typedef TGpuParamLoadStoreTexture<true> GpuParamLoadStoreTextureCore;
|
|
|
}
|