summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-08-28 14:42:08 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-08-28 14:42:08 +0000
commitad97af5a953b8c158e0896ae25e72afe4d1c3a9e (patch)
treee76a9ef4dffa2d63ba2cf339918841b5effe6d6e /Graphics/GraphicsEngine
parentUpdated LockHelper to spin few times before yielding thread (diff)
downloadDiligentCore-ad97af5a953b8c158e0896ae25e72afe4d1c3a9e.tar.gz
DiligentCore-ad97af5a953b8c158e0896ae25e72afe4d1c3a9e.zip
Fixed https://github.com/DiligentGraphics/DiligentCore/issues/17 (Add support for Update Texture on DX12)
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/interface/Texture.h55
-rw-r--r--Graphics/GraphicsEngine/src/Texture.cpp6
2 files changed, 30 insertions, 31 deletions
diff --git a/Graphics/GraphicsEngine/interface/Texture.h b/Graphics/GraphicsEngine/interface/Texture.h
index 7dddd917..121a86c3 100644
--- a/Graphics/GraphicsEngine/interface/Texture.h
+++ b/Graphics/GraphicsEngine/interface/Texture.h
@@ -194,18 +194,22 @@ struct TextureSubResData
{
/// Pointer to the subresource data in CPU memory.
/// If provided, pSrcBuffer must be null
- const void* pData;
+ const void* pData = nullptr;
/// Pointer to the GPU buffer that contains subresource data.
/// If provided, pData must be null
- class IBuffer *pSrcBuffer;
+ class IBuffer* pSrcBuffer = nullptr;
+
+ /// When updating data from the buffer (pSrcBuffer is not null),
+ /// offset from the beginning of the buffer to the data start
+ Uint32 SrcOffset = 0;
/// For 2D and 3D textures, row stride in bytes
- Uint32 Stride;
+ Uint32 Stride = 0;
/// For 3D textures, depth slice stride in bytes
/// \note On OpenGL, this must be a mutliple of Stride
- Uint32 DepthStride;
+ Uint32 DepthStride = 0;
/// Initializes the structure members with default values
@@ -213,29 +217,27 @@ struct TextureSubResData
/// Member | Default value
/// ----------------|--------------
/// pData | nullptr
+ /// SrcOffset | 0
/// Stride | 0
/// DepthStride | 0
- TextureSubResData():
- pData(nullptr),
- pSrcBuffer(nullptr),
- Stride(0),
- DepthStride(0)
- {}
+ TextureSubResData(){}
/// Initializes the structure members to perform copy from the CPU memory
- TextureSubResData(void *_pData, Uint32 _Stride, Uint32 _DepthStride=0) :
- pData(_pData),
- pSrcBuffer(nullptr),
- Stride(_Stride),
- DepthStride(_DepthStride)
+ TextureSubResData(void *_pData, Uint32 _Stride, Uint32 _DepthStride = 0) :
+ pData (_pData),
+ pSrcBuffer (nullptr),
+ SrcOffset (0),
+ Stride (_Stride),
+ DepthStride (_DepthStride)
{}
/// Initializes the structure members to perform copy from the GPU buffer
- TextureSubResData(IBuffer *_pBuffer, Uint32 _Stride, Uint32 _DepthStride=0) :
- pData(nullptr),
- pSrcBuffer(_pBuffer),
- Stride(_Stride),
- DepthStride(_DepthStride)
+ TextureSubResData(IBuffer *_pBuffer, Uint32 _SrcOffset, Uint32 _Stride, Uint32 _DepthStride = 0) :
+ pData (nullptr),
+ pSrcBuffer (_pBuffer),
+ SrcOffset (_SrcOffset),
+ Stride (_Stride),
+ DepthStride (_DepthStride)
{}
};
@@ -244,13 +246,13 @@ struct TextureData
{
/// Pointer to the array of the TextureSubResData elements containing
/// information about each subresource.
- TextureSubResData *pSubResources;
+ TextureSubResData* pSubResources = nullptr;
/// Number of elements in pSubResources array.
/// NumSubresources must exactly match the number
/// of subresources in the texture. Otherwise an error
/// occurs.
- Uint32 NumSubresources;
+ Uint32 NumSubresources = 0;
/// Initializes the structure members with default values
@@ -259,16 +261,13 @@ struct TextureData
/// ----------------|--------------
/// pSubResources | nullptr
/// NumSubresources | 0
- TextureData() :
- pSubResources(nullptr),
- NumSubresources(0)
- {}
+ TextureData(){}
};
struct MappedTextureSubresource
{
- PVoid pData = nullptr;
- Uint32 Stride = 0;
+ PVoid pData = nullptr;
+ Uint32 Stride = 0;
Uint32 DepthStride = 0;
};
diff --git a/Graphics/GraphicsEngine/src/Texture.cpp b/Graphics/GraphicsEngine/src/Texture.cpp
index 5e7dc932..c459fa59 100644
--- a/Graphics/GraphicsEngine/src/Texture.cpp
+++ b/Graphics/GraphicsEngine/src/Texture.cpp
@@ -117,9 +117,9 @@ void ValidateTextureRegion(const TextureDesc &TexDesc, Uint32 MipLevel, Uint32 S
#define VERIFY_TEX_PARAMS(Expr, ...) if(!(Expr))LOG_ERROR("Texture \"", TexDesc.Name ? TexDesc.Name : "", "\": ", ##__VA_ARGS__)
#ifdef DEVELOPMENT
VERIFY_TEX_PARAMS( MipLevel < TexDesc.MipLevels, "Mip level (", MipLevel, ") is out of allowed range [0, ", TexDesc.MipLevels-1, "]" );
- VERIFY_TEX_PARAMS( Box.MinX < Box.MaxX, "X range of the update region is invalid: ", Box.MinX, "..", Box.MaxX);
- VERIFY_TEX_PARAMS( Box.MinY < Box.MaxY, "Y range of the update region is invalid: ", Box.MinY, "..", Box.MaxY);
- VERIFY_TEX_PARAMS( Box.MinZ < Box.MaxZ, "Z range of the update region is invalid: ", Box.MinZ, "..", Box.MaxZ);
+ VERIFY_TEX_PARAMS( Box.MinX < Box.MaxX, "Invalid X range: ", Box.MinX, "..", Box.MaxX);
+ VERIFY_TEX_PARAMS( Box.MinY < Box.MaxY, "Invalid Y range: ", Box.MinY, "..", Box.MaxY);
+ VERIFY_TEX_PARAMS( Box.MinZ < Box.MaxZ, "Invalid Z range: ", Box.MinZ, "..", Box.MaxZ);
if( TexDesc.Type == RESOURCE_DIM_TEX_1D_ARRAY ||
TexDesc.Type == RESOURCE_DIM_TEX_2D_ARRAY ||