Revision: 2215
Author: mike.popoloski
Date: Sun May 18 20:47:59 2014 UTC
Log: Fixing subresource size calculations for compressed textures that
are smaller than 4x4.
http://code.google.com/p/slimdx/source/detail?r=2215
Modified:
/branches/vs2013/source/DataStream.cpp
/branches/vs2013/source/direct3d11/DeviceContext11.cpp
/branches/vs2013/source/stdafx.h
=======================================
--- /branches/vs2013/source/DataStream.cpp Sun May 18 20:39:07 2014 UTC
+++ /branches/vs2013/source/DataStream.cpp Sun May 18 20:47:59 2014 UTC
@@ -306,7 +306,7 @@
//Truncate the count to the end of the stream
Int64 elementSize = static_cast<Int64>( sizeof(T) );
- size_t actualCount = min( static_cast<size_t>((Length - m_Position) /
elementSize), static_cast<size_t>( count ) );
+ size_t actualCount = std::min( static_cast<size_t>((Length - m_Position)
/ elementSize), static_cast<size_t>( count ) );
pin_ptr<T> pinnedBuffer = &buffer[offset];
memcpy( pinnedBuffer, m_Buffer + m_Position, static_cast<size_t>(
actualCount * elementSize ) );
@@ -324,7 +324,7 @@
//Truncate the count to the end of the stream
Int64 elementSize = static_cast<Int64>( sizeof(T) );
- size_t actualCount = min( static_cast<size_t>((Length - m_Position) /
elementSize), static_cast<size_t>( count ) );
+ size_t actualCount = std::min( static_cast<size_t>((Length - m_Position)
/ elementSize), static_cast<size_t>( count ) );
array<T>^ result = gcnew array<T>( static_cast<int>( actualCount ) );
pin_ptr<T> pinnedBuffer = &result[0];
=======================================
--- /branches/vs2013/source/direct3d11/DeviceContext11.cpp Sun May 18
20:39:07 2014 UTC
+++ /branches/vs2013/source/direct3d11/DeviceContext11.cpp Sun May 18
20:47:59 2014 UTC
@@ -339,7 +339,7 @@
DataBox^ DeviceContext::MapSubresource(Texture1D^ resource, int mipSlice,
int arraySlice, MapMode mode, MapFlags flags)
{
Texture1DDescription desc = resource->Description;
- int sizeInBytes = Resource::GetMipSize(mipSlice, desc.Width) *
Utilities::SizeOfFormatElement(static_cast<DXGI_FORMAT>(desc.Format));
+ int sizeInBytes = Resource::GetMipSize(mipSlice, desc.Width) *
Utilities::SizeOfFormatElement(static_cast<DXGI_FORMAT>(desc.Format)) / 8;
int subresource = D3D11CalcSubresource(mipSlice, arraySlice,
desc.MipLevels);
D3D11_MAPPED_SUBRESOURCE mapped;
@@ -361,6 +361,9 @@
if (RECORD_D3D11(hr).IsFailure)
return nullptr;
+ if (Utilities::IsCompressed(static_cast<DXGI_FORMAT>(desc.Format)))
+ mipHeight = std::max(1, mipHeight / 4);
+
return gcnew DataBox(mapped.RowPitch, mapped.DepthPitch, gcnew
DataStream(mapped.pData, mipHeight * mapped.RowPitch, true, true, false));
}
=======================================
--- /branches/vs2013/source/stdafx.h Sun May 18 20:39:07 2014 UTC
+++ /branches/vs2013/source/stdafx.h Sun May 18 20:47:59 2014 UTC
@@ -20,6 +20,8 @@
* THE SOFTWARE.
*/
+#define NOMINMAX
+
#include <InitGuid.h> // include these two headers in this order or die a
horrible firey GUID related death
#include <CGuid.h>
@@ -37,6 +39,7 @@
#include <stdexcept>
#include <cmath>
#include <cassert>
+#include <algorithm>
#pragma warning(push)
#pragma warning(disable : 4005)