Branimir Karadžić 9 лет назад
Родитель
Сommit
b62fe2749f
5 измененных файлов с 18 добавлено и 5 удалено
  1. 14 5
      src/renderer_d3d11.cpp
  2. 1 0
      src/renderer_d3d12.cpp
  3. 1 0
      src/renderer_d3d9.cpp
  4. 1 0
      src/renderer_gl.cpp
  5. 1 0
      src/renderer_mtl.mm

+ 14 - 5
src/renderer_d3d11.cpp

@@ -4659,8 +4659,9 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 
 
 		const uint32_t subres = _mip + ( (layer + _side) * m_numMips);
 		const uint32_t subres = _mip + ( (layer + _side) * m_numMips);
 		const uint32_t bpp    = getBitsPerPixel(TextureFormat::Enum(m_textureFormat) );
 		const uint32_t bpp    = getBitsPerPixel(TextureFormat::Enum(m_textureFormat) );
-		const uint32_t rectpitch = _rect.m_width*bpp/8;
-		const uint32_t srcpitch  = UINT16_MAX == _pitch ? rectpitch : _pitch;
+		const uint32_t rectpitch  = _rect.m_width*bpp/8;
+		const uint32_t srcpitch   = UINT16_MAX == _pitch ? rectpitch : _pitch;
+		const uint32_t slicepitch = rectpitch*_rect.m_height;
 
 
 		const bool convert = m_textureFormat != m_requestedFormat;
 		const bool convert = m_textureFormat != m_requestedFormat;
 
 
@@ -4669,12 +4670,19 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 
 
 		if (convert)
 		if (convert)
 		{
 		{
-			temp = (uint8_t*)BX_ALLOC(g_allocator, rectpitch*_rect.m_height);
+			temp = (uint8_t*)BX_ALLOC(g_allocator, slicepitch);
 			imageDecodeToBgra8(temp, data, _rect.m_width, _rect.m_height, srcpitch, TextureFormat::Enum(m_requestedFormat) );
 			imageDecodeToBgra8(temp, data, _rect.m_width, _rect.m_height, srcpitch, TextureFormat::Enum(m_requestedFormat) );
 			data = temp;
 			data = temp;
 		}
 		}
 
 
-		deviceCtx->UpdateSubresource(m_ptr, subres, &box, data, srcpitch, 0);
+		deviceCtx->UpdateSubresource(
+			  m_ptr
+			, subres
+			, &box
+			, data
+			, srcpitch
+			, TextureD3D11::Texture3D == m_type ? slicepitch : 0
+			);
 
 
 		if (NULL != temp)
 		if (NULL != temp)
 		{
 		{
@@ -4729,7 +4737,8 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 		m_dsv       = NULL;
 		m_dsv       = NULL;
 		m_swapChain = NULL;
 		m_swapChain = NULL;
 
 
-		m_numTh = _num;
+		m_denseIdx = UINT16_MAX;
+		m_numTh    = _num;
 		m_needPresent = false;
 		m_needPresent = false;
 		memcpy(m_attachment, _attachment, _num*sizeof(Attachment) );
 		memcpy(m_attachment, _attachment, _num*sizeof(Attachment) );
 
 

+ 1 - 0
src/renderer_d3d12.cpp

@@ -4429,6 +4429,7 @@ data.NumQualityLevels = 0;
 
 
 	void FrameBufferD3D12::create(uint8_t _num, const Attachment* _attachment)
 	void FrameBufferD3D12::create(uint8_t _num, const Attachment* _attachment)
 	{
 	{
+		m_denseIdx = UINT16_MAX;
 		m_numTh = _num;
 		m_numTh = _num;
 		memcpy(m_attachment, _attachment, _num*sizeof(Attachment) );
 		memcpy(m_attachment, _attachment, _num*sizeof(Attachment) );
 
 

+ 1 - 0
src/renderer_d3d9.cpp

@@ -3154,6 +3154,7 @@ namespace bgfx { namespace d3d9
 			m_surface[ii] = NULL;
 			m_surface[ii] = NULL;
 		}
 		}
 
 
+		m_denseIdx = UINT16_MAX;
 		m_dsIdx = UINT8_MAX;
 		m_dsIdx = UINT8_MAX;
 		m_num   = 0;
 		m_num   = 0;
 		m_numTh = _num;
 		m_numTh = _num;

+ 1 - 0
src/renderer_gl.cpp

@@ -5812,6 +5812,7 @@ namespace bgfx { namespace gl
 	{
 	{
 		GL_CHECK(glGenFramebuffers(1, &m_fbo[0]) );
 		GL_CHECK(glGenFramebuffers(1, &m_fbo[0]) );
 
 
+		m_denseIdx = UINT16_MAX;
 		m_numTh = _num;
 		m_numTh = _num;
 		memcpy(m_attachment, _attachment, _num*sizeof(Attachment) );
 		memcpy(m_attachment, _attachment, _num*sizeof(Attachment) );
 
 

+ 1 - 0
src/renderer_mtl.mm

@@ -2689,6 +2689,7 @@ namespace bgfx { namespace mtl
 
 
 	void FrameBufferMtl::create(uint8_t _num, const Attachment* _attachment)
 	void FrameBufferMtl::create(uint8_t _num, const Attachment* _attachment)
 	{
 	{
+		m_denseIdx = UINT16_MAX;
 		m_num = 0;
 		m_num = 0;
 		m_width = 0;
 		m_width = 0;
 		m_height = 0;
 		m_height = 0;