Conformance and minor code cleanup (#90)
This commit is contained in:
Родитель
2ef1162357
Коммит
cac6bb3175
|
@ -74,7 +74,7 @@ namespace DirectX
|
|||
psoDesc.IBStripCutValue = stripCutValue;
|
||||
psoDesc.PrimitiveTopologyType = primitiveTopology;
|
||||
psoDesc.NumRenderTargets = renderTargetState.numRenderTargets;
|
||||
memcpy_s(psoDesc.RTVFormats, sizeof(psoDesc.RTVFormats), renderTargetState.rtvFormats, sizeof(DXGI_FORMAT) * D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT);
|
||||
memcpy(psoDesc.RTVFormats, renderTargetState.rtvFormats, sizeof(DXGI_FORMAT) * D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT);
|
||||
psoDesc.DSVFormat = renderTargetState.dsvFormat;
|
||||
psoDesc.SampleDesc = renderTargetState.sampleDesc;
|
||||
psoDesc.NodeMask = renderTargetState.nodeMask;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <d3d12_x.h>
|
||||
#else
|
||||
#include <d3d12.h>
|
||||
#include <dxgi.h>
|
||||
#include <dxgi1_4.h>
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
|
@ -58,7 +58,8 @@ namespace DirectX
|
|||
rtvFormats[0] = rtFormat;
|
||||
}
|
||||
|
||||
// Convenience constructor converting from DXGI_SWAPCHAIN_DESC
|
||||
// Convenience constructors converting from DXGI_SWAPCHAIN_DESC
|
||||
#if defined(__dxgi_h__) || defined(__d3d11_x_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__)
|
||||
RenderTargetState(
|
||||
_In_ const DXGI_SWAP_CHAIN_DESC* desc,
|
||||
_In_ DXGI_FORMAT dsFormat) noexcept
|
||||
|
@ -72,6 +73,23 @@ namespace DirectX
|
|||
rtvFormats[0] = desc->BufferDesc.Format;
|
||||
sampleDesc = desc->SampleDesc;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__dxgi1_2_h__) || defined(__d3d11_x_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__)
|
||||
RenderTargetState(
|
||||
_In_ const DXGI_SWAP_CHAIN_DESC1* desc,
|
||||
_In_ DXGI_FORMAT dsFormat) noexcept
|
||||
: sampleMask(UINT_MAX)
|
||||
, numRenderTargets(1)
|
||||
, rtvFormats{}
|
||||
, dsvFormat(dsFormat)
|
||||
, sampleDesc{}
|
||||
, nodeMask(0)
|
||||
{
|
||||
rtvFormats[0] = desc->Format;
|
||||
sampleDesc = desc->SampleDesc;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t sampleMask;
|
||||
uint32_t numRenderTargets;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#if !(defined(_XBOX_ONE) && defined(_TITLE)) && !defined(_GAMING_XBOX)
|
||||
#if (defined(WIN32) || defined(WINAPI_FAMILY)) && !(defined(_XBOX_ONE) && defined(_TITLE)) && !defined(_GAMING_XBOX)
|
||||
#include <dxgi1_2.h>
|
||||
#endif
|
||||
|
||||
|
@ -474,7 +474,7 @@ namespace DirectX
|
|||
r1.x, r1.y, r1.z, r1.w,
|
||||
r2.x, r2.y, r2.z, r2.w,
|
||||
r3.x, r3.y, r3.z, r3.w) {}
|
||||
Matrix(const XMFLOAT4X4& M) noexcept { memcpy_s(this, sizeof(float) * 16, &M, sizeof(XMFLOAT4X4)); }
|
||||
Matrix(const XMFLOAT4X4& M) noexcept { memcpy(this, &M, sizeof(XMFLOAT4X4)); }
|
||||
Matrix(const XMFLOAT3X3& M) noexcept;
|
||||
Matrix(const XMFLOAT4X3& M) noexcept;
|
||||
|
||||
|
@ -927,7 +927,9 @@ namespace DirectX
|
|||
void Unproject(const Vector3& p, const Matrix& proj, const Matrix& view, const Matrix& world, Vector3& result) const noexcept;
|
||||
|
||||
// Static methods
|
||||
#if defined(__dxgi1_2_h__) || defined(__d3d11_x_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__)
|
||||
static RECT __cdecl ComputeDisplayArea(DXGI_SCALING scaling, UINT backBufferWidth, UINT backBufferHeight, int outputWidth, int outputHeight) noexcept;
|
||||
#endif
|
||||
static RECT __cdecl ComputeTitleSafeArea(UINT backBufferWidth, UINT backBufferHeight) noexcept;
|
||||
};
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <d3d12_x.h>
|
||||
#else
|
||||
#include <d3d12.h>
|
||||
#include <dxgi.h>
|
||||
#include <dxgi1_4.h>
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
|
@ -126,8 +126,10 @@ namespace DirectX
|
|||
void XM_CALLCONV Draw(D3D12_GPU_DESCRIPTOR_HANDLE textureSRV, XMUINT2 const& textureSize, RECT const& destinationRectangle, _In_opt_ RECT const* sourceRectangle, FXMVECTOR color = Colors::White, float rotation = 0, XMFLOAT2 const& origin = Float2Zero, SpriteEffects effects = SpriteEffects_None, float layerDepth = 0);
|
||||
|
||||
// Rotation mode to be applied to the sprite transformation
|
||||
#if defined(__dxgi1_2_h__) || defined(__d3d11_x_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__)
|
||||
void __cdecl SetRotation(DXGI_MODE_ROTATION mode);
|
||||
DXGI_MODE_ROTATION __cdecl GetRotation() const noexcept;
|
||||
#endif
|
||||
|
||||
// Set viewport for sprite transformation
|
||||
void __cdecl SetViewport(const D3D12_VIEWPORT& viewPort);
|
||||
|
|
|
@ -10,11 +10,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace DirectX
|
||||
{
|
||||
|
@ -36,8 +39,13 @@ namespace DirectX
|
|||
static_assert(alignment > 8, "AlignedNew is only useful for types with > 8 byte alignment. Did you forget a __declspec(align) on TDerived?");
|
||||
static_assert(((alignment - 1) & alignment) == 0, "AlignedNew only works with power of two alignment");
|
||||
|
||||
#ifdef WIN32
|
||||
void* ptr = _aligned_malloc(size, alignment);
|
||||
|
||||
#else
|
||||
// This C++17 Standard Library function is currently NOT
|
||||
// implemented for the Microsoft Standard C++ Library.
|
||||
void* ptr = aligned_alloc(alignment, size);
|
||||
#endif
|
||||
if (!ptr)
|
||||
throw std::bad_alloc();
|
||||
|
||||
|
@ -48,13 +56,19 @@ namespace DirectX
|
|||
// Free aligned memory.
|
||||
static void operator delete (void* ptr)
|
||||
{
|
||||
#ifdef WIN32
|
||||
_aligned_free(ptr);
|
||||
#else
|
||||
free(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Array overloads.
|
||||
static void* operator new[](size_t size)
|
||||
{
|
||||
static_assert((sizeof(TDerived) % alignof(TDerived) == 0), "AlignedNew expects type to be padded to the alignment");
|
||||
|
||||
return operator new(size);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,9 +51,6 @@ namespace Bezier
|
|||
template<typename T>
|
||||
inline T CubicTangent(T const& p1, T const& p2, T const& p3, T const& p4, float t) noexcept
|
||||
{
|
||||
using DirectX::operator*;
|
||||
using DirectX::operator+;
|
||||
|
||||
return p1 * (-1 + 2 * t - t * t) +
|
||||
p2 * (1 - 4 * t + 3 * t * t) +
|
||||
p3 * (2 * t - 3 * t * t) +
|
||||
|
|
|
@ -127,8 +127,9 @@ size_t EffectTextureFactory::Impl::CreateTexture(_In_z_ const wchar_t* name, int
|
|||
}
|
||||
}
|
||||
|
||||
wchar_t ext[_MAX_EXT];
|
||||
wchar_t ext[_MAX_EXT] = {};
|
||||
_wsplitpath_s(name, nullptr, 0, nullptr, 0, nullptr, 0, ext, _MAX_EXT);
|
||||
bool isdds = _wcsicmp(ext, L".dds") == 0;
|
||||
|
||||
DDS_LOADER_FLAGS loadFlags = DDS_LOADER_DEFAULT;
|
||||
if (mForceSRGB)
|
||||
|
@ -136,12 +137,7 @@ size_t EffectTextureFactory::Impl::CreateTexture(_In_z_ const wchar_t* name, int
|
|||
if (mAutoGenMips)
|
||||
loadFlags |= DDS_LOADER_MIP_AUTOGEN;
|
||||
|
||||
static_assert(static_cast<int>(DDS_LOADER_DEFAULT) == static_cast<int>(WIC_LOADER_DEFAULT), "DDS/WIC Load flags mismatch");
|
||||
static_assert(static_cast<int>(DDS_LOADER_FORCE_SRGB) == static_cast<int>(WIC_LOADER_FORCE_SRGB), "DDS/WIC Load flags mismatch");
|
||||
static_assert(static_cast<int>(DDS_LOADER_MIP_AUTOGEN) == static_cast<int>(WIC_LOADER_MIP_AUTOGEN), "DDS/WIC Load flags mismatch");
|
||||
static_assert(static_cast<int>(DDS_LOADER_MIP_RESERVE) == static_cast<int>(WIC_LOADER_MIP_RESERVE), "DDS/WIC Load flags mismatch");
|
||||
|
||||
if (_wcsicmp(ext, L".dds") == 0)
|
||||
if (isdds)
|
||||
{
|
||||
HRESULT hr = CreateDDSTextureFromFileEx(
|
||||
mDevice.Get(),
|
||||
|
@ -162,6 +158,11 @@ size_t EffectTextureFactory::Impl::CreateTexture(_In_z_ const wchar_t* name, int
|
|||
}
|
||||
else
|
||||
{
|
||||
static_assert(static_cast<int>(DDS_LOADER_DEFAULT) == static_cast<int>(WIC_LOADER_DEFAULT), "DDS/WIC Load flags mismatch");
|
||||
static_assert(static_cast<int>(DDS_LOADER_FORCE_SRGB) == static_cast<int>(WIC_LOADER_FORCE_SRGB), "DDS/WIC Load flags mismatch");
|
||||
static_assert(static_cast<int>(DDS_LOADER_MIP_AUTOGEN) == static_cast<int>(WIC_LOADER_MIP_AUTOGEN), "DDS/WIC Load flags mismatch");
|
||||
static_assert(static_cast<int>(DDS_LOADER_MIP_RESERVE) == static_cast<int>(WIC_LOADER_MIP_RESERVE), "DDS/WIC Load flags mismatch");
|
||||
|
||||
textureEntry.mIsCubeMap = false;
|
||||
|
||||
HRESULT hr = CreateWICTextureFromFileEx(
|
||||
|
|
|
@ -53,11 +53,26 @@ namespace
|
|||
// 4 - 16k allocator
|
||||
// etc...
|
||||
// Need to convert to an index.
|
||||
DWORD bitIndex = 0;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
unsigned long bitIndex = 0;
|
||||
|
||||
#ifdef _WIN64
|
||||
return _BitScanForward64(&bitIndex, allocatorPageSize) ? bitIndex + 1 : 0;
|
||||
#else
|
||||
return _BitScanForward(&bitIndex, static_cast<DWORD>(allocatorPageSize)) ? bitIndex + 1 : 0;
|
||||
return _BitScanForward(&bitIndex, static_cast<unsigned long>(allocatorPageSize)) ? bitIndex + 1 : 0;
|
||||
#endif
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
|
||||
#ifdef __LP64__
|
||||
return static_cast<size_t>(__builtin_ffsll(static_cast<long long>(allocatorPageSize)));
|
||||
#else
|
||||
return static_cast<size_t>(__builtin_ffs(static_cast<int>(allocatorPageSize)));
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error Unknown forward bit-scan syntax
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -171,7 +186,7 @@ namespace
|
|||
size_t totalPageCount = 0;
|
||||
size_t committedMemoryUsage = 0;
|
||||
size_t totalMemoryUsage = 0;
|
||||
|
||||
|
||||
ScopedLock lock(mMutex);
|
||||
|
||||
for (auto& i : mPools)
|
||||
|
@ -346,7 +361,7 @@ GraphicsMemory::GraphicsMemory(GraphicsMemory&& moveFrom) noexcept
|
|||
|
||||
// Move assignment.
|
||||
GraphicsMemory& GraphicsMemory::operator= (GraphicsMemory&& moveFrom) noexcept
|
||||
{
|
||||
{
|
||||
pImpl = std::move(moveFrom.pImpl);
|
||||
pImpl->mOwner = this;
|
||||
return *this;
|
||||
|
@ -586,4 +601,3 @@ void SharedGraphicsResource::Reset(const SharedGraphicsResource& resource) noexc
|
|||
{
|
||||
mSharedResource = resource.mSharedResource;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
using namespace DirectX;
|
||||
|
||||
#ifndef _CPPRTTI
|
||||
#if !defined(_CPPRTTI) && !defined(__GXX_RTTI)
|
||||
#error Model requires RTTI
|
||||
#endif
|
||||
|
||||
|
|
|
@ -71,6 +71,12 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
template<size_t sizeOfBuffer>
|
||||
inline void ASCIIToWChar(wchar_t (&buffer)[sizeOfBuffer], const char *ascii)
|
||||
{
|
||||
MultiByteToWideChar(CP_UTF8, 0, ascii, -1, buffer, sizeOfBuffer);
|
||||
}
|
||||
|
||||
void InitMaterial(
|
||||
const DXUT::SDKMESH_MATERIAL& mh,
|
||||
unsigned int flags,
|
||||
|
@ -79,16 +85,16 @@ namespace
|
|||
bool srgb)
|
||||
{
|
||||
wchar_t matName[DXUT::MAX_MATERIAL_NAME] = {};
|
||||
MultiByteToWideChar(CP_UTF8, 0, mh.Name, -1, matName, DXUT::MAX_MATERIAL_NAME);
|
||||
ASCIIToWChar(matName, mh.Name);
|
||||
|
||||
wchar_t diffuseName[DXUT::MAX_TEXTURE_NAME] = {};
|
||||
MultiByteToWideChar(CP_UTF8, 0, mh.DiffuseTexture, -1, diffuseName, DXUT::MAX_TEXTURE_NAME);
|
||||
ASCIIToWChar(diffuseName, mh.DiffuseTexture);
|
||||
|
||||
wchar_t specularName[DXUT::MAX_TEXTURE_NAME] = {};
|
||||
MultiByteToWideChar(CP_UTF8, 0, mh.SpecularTexture, -1, specularName, DXUT::MAX_TEXTURE_NAME);
|
||||
ASCIIToWChar(specularName, mh.SpecularTexture);
|
||||
|
||||
wchar_t normalName[DXUT::MAX_TEXTURE_NAME] = {};
|
||||
MultiByteToWideChar(CP_UTF8, 0, mh.NormalTexture, -1, normalName, DXUT::MAX_TEXTURE_NAME);
|
||||
ASCIIToWChar(normalName, mh.NormalTexture);
|
||||
|
||||
if ((flags & DUAL_TEXTURE) && !mh.SpecularTexture[0])
|
||||
{
|
||||
|
@ -160,19 +166,19 @@ namespace
|
|||
_Inout_ std::map<std::wstring, int>& textureDictionary)
|
||||
{
|
||||
wchar_t matName[DXUT::MAX_MATERIAL_NAME] = {};
|
||||
MultiByteToWideChar(CP_UTF8, 0, mh.Name, -1, matName, DXUT::MAX_MATERIAL_NAME);
|
||||
ASCIIToWChar(matName, mh.Name);
|
||||
|
||||
wchar_t albetoTexture[DXUT::MAX_TEXTURE_NAME] = {};
|
||||
MultiByteToWideChar(CP_UTF8, 0, mh.AlbetoTexture, -1, albetoTexture, DXUT::MAX_TEXTURE_NAME);
|
||||
ASCIIToWChar(albetoTexture, mh.AlbetoTexture);
|
||||
|
||||
wchar_t normalName[DXUT::MAX_TEXTURE_NAME] = {};
|
||||
MultiByteToWideChar(CP_UTF8, 0, mh.NormalTexture, -1, normalName, DXUT::MAX_TEXTURE_NAME);
|
||||
ASCIIToWChar(normalName, mh.NormalTexture);
|
||||
|
||||
wchar_t rmaName[DXUT::MAX_TEXTURE_NAME] = {};
|
||||
MultiByteToWideChar(CP_UTF8, 0, mh.RMATexture, -1, rmaName, DXUT::MAX_TEXTURE_NAME);
|
||||
ASCIIToWChar(rmaName, mh.RMATexture);
|
||||
|
||||
wchar_t emissiveName[DXUT::MAX_TEXTURE_NAME] = {};
|
||||
MultiByteToWideChar(CP_UTF8, 0, mh.EmissiveTexture, -1, emissiveName, DXUT::MAX_TEXTURE_NAME);
|
||||
ASCIIToWChar(emissiveName, mh.EmissiveTexture);
|
||||
|
||||
m = {};
|
||||
m.name = matName;
|
||||
|
@ -591,7 +597,8 @@ std::unique_ptr<Model> DirectX::Model::CreateFromSDKMESH(
|
|||
|
||||
auto mesh = std::make_shared<ModelMesh>();
|
||||
wchar_t meshName[DXUT::MAX_MESH_NAME] = {};
|
||||
MultiByteToWideChar(CP_UTF8, 0, mh.Name, -1, meshName, DXUT::MAX_MESH_NAME);
|
||||
ASCIIToWChar(meshName, mh.Name);
|
||||
|
||||
mesh->name = meshName;
|
||||
|
||||
// Extents
|
||||
|
|
|
@ -298,30 +298,30 @@ HRESULT DirectX::SaveDDSTextureToFile(
|
|||
DDS_HEADER_DXT10* extHeader = nullptr;
|
||||
switch (desc.Format)
|
||||
{
|
||||
case DXGI_FORMAT_R8G8B8A8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A8B8G8R8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_R16G16_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_G16R16, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_R8G8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A8L8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_R16_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_L16, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_R8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_L8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_A8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_R8G8_B8G8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_R8G8_B8G8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_G8R8_G8B8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_G8R8_G8B8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_BC1_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_DXT1, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_BC2_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_DXT3, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_BC3_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_DXT5, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_BC4_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_BC4_UNORM, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_BC4_SNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_BC4_SNORM, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_BC5_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_BC5_UNORM, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_BC5_SNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_BC5_SNORM, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_B5G6R5_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_R5G6B5, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_B5G5R5A1_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A1R5G5B5, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_R8G8_SNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_V8U8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_R8G8B8A8_SNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_Q8W8V8U8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_R16G16_SNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_V16U16, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_B8G8R8A8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A8R8G8B8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_B8G8R8X8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_X8R8G8B8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_YUY2: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_YUY2, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_B4G4R4A4_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A4R4G4B4, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_R8G8B8A8_UNORM: memcpy(&header->ddspf, &DDSPF_A8B8G8R8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_R16G16_UNORM: memcpy(&header->ddspf, &DDSPF_G16R16, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_R8G8_UNORM: memcpy(&header->ddspf, &DDSPF_A8L8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_R16_UNORM: memcpy(&header->ddspf, &DDSPF_L16, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_R8_UNORM: memcpy(&header->ddspf, &DDSPF_L8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_A8_UNORM: memcpy(&header->ddspf, &DDSPF_A8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_R8G8_B8G8_UNORM: memcpy(&header->ddspf, &DDSPF_R8G8_B8G8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_G8R8_G8B8_UNORM: memcpy(&header->ddspf, &DDSPF_G8R8_G8B8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_BC1_UNORM: memcpy(&header->ddspf, &DDSPF_DXT1, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_BC2_UNORM: memcpy(&header->ddspf, &DDSPF_DXT3, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_BC3_UNORM: memcpy(&header->ddspf, &DDSPF_DXT5, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_BC4_UNORM: memcpy(&header->ddspf, &DDSPF_BC4_UNORM, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_BC4_SNORM: memcpy(&header->ddspf, &DDSPF_BC4_SNORM, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_BC5_UNORM: memcpy(&header->ddspf, &DDSPF_BC5_UNORM, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_BC5_SNORM: memcpy(&header->ddspf, &DDSPF_BC5_SNORM, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_B5G6R5_UNORM: memcpy(&header->ddspf, &DDSPF_R5G6B5, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_B5G5R5A1_UNORM: memcpy(&header->ddspf, &DDSPF_A1R5G5B5, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_R8G8_SNORM: memcpy(&header->ddspf, &DDSPF_V8U8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_R8G8B8A8_SNORM: memcpy(&header->ddspf, &DDSPF_Q8W8V8U8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_R16G16_SNORM: memcpy(&header->ddspf, &DDSPF_V16U16, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_B8G8R8A8_UNORM: memcpy(&header->ddspf, &DDSPF_A8R8G8B8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_B8G8R8X8_UNORM: memcpy(&header->ddspf, &DDSPF_X8R8G8B8, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_YUY2: memcpy(&header->ddspf, &DDSPF_YUY2, sizeof(DDS_PIXELFORMAT)); break;
|
||||
case DXGI_FORMAT_B4G4R4A4_UNORM: memcpy(&header->ddspf, &DDSPF_A4R4G4B4, sizeof(DDS_PIXELFORMAT)); break;
|
||||
|
||||
// Legacy D3DX formats using D3DFMT enum value as FourCC
|
||||
case DXGI_FORMAT_R32G32B32A32_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 116; break; // D3DFMT_A32B32G32R32F
|
||||
|
@ -341,7 +341,7 @@ HRESULT DirectX::SaveDDSTextureToFile(
|
|||
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
|
||||
|
||||
default:
|
||||
memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_DX10, sizeof(DDS_PIXELFORMAT));
|
||||
memcpy(&header->ddspf, &DDSPF_DX10, sizeof(DDS_PIXELFORMAT));
|
||||
|
||||
headerSize += sizeof(DDS_HEADER_DXT10);
|
||||
extHeader = reinterpret_cast<DDS_HEADER_DXT10*>(fileHeader + sizeof(uint32_t) + sizeof(DDS_HEADER));
|
||||
|
@ -401,7 +401,7 @@ HRESULT DirectX::SaveDDSTextureToFile(
|
|||
size_t msize = std::min<size_t>(rowPitch, size_t(dstRowPitch));
|
||||
for (size_t h = 0; h < rowCount; ++h)
|
||||
{
|
||||
memcpy_s(dptr, rowPitch, sptr, msize);
|
||||
memcpy(dptr, sptr, msize);
|
||||
sptr += dstRowPitch;
|
||||
dptr += rowPitch;
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ static_assert(offsetof(DirectX::SimpleMath::Viewport, minDepth) == offsetof(D3D1
|
|||
static_assert(offsetof(DirectX::SimpleMath::Viewport, maxDepth) == offsetof(D3D12_VIEWPORT, MaxDepth), "Layout mismatch");
|
||||
#endif
|
||||
|
||||
#if defined(__dxgi1_2_h__) || defined(__d3d11_x_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__)
|
||||
RECT DirectX::SimpleMath::Viewport::ComputeDisplayArea(DXGI_SCALING scaling, UINT backBufferWidth, UINT backBufferHeight, int outputWidth, int outputHeight) noexcept
|
||||
{
|
||||
RECT rct = {};
|
||||
|
@ -140,6 +141,7 @@ RECT DirectX::SimpleMath::Viewport::ComputeDisplayArea(DXGI_SCALING scaling, UIN
|
|||
|
||||
return rct;
|
||||
}
|
||||
#endif
|
||||
|
||||
RECT DirectX::SimpleMath::Viewport::ComputeTitleSafeArea(UINT backBufferWidth, UINT backBufferHeight) noexcept
|
||||
{
|
||||
|
|
|
@ -200,7 +200,7 @@ private:
|
|||
ComPtr<ID3D12Resource> indexBuffer;
|
||||
D3D12_INDEX_BUFFER_VIEW indexBufferView;
|
||||
ComPtr<ID3D12RootSignature> rootSignatureStatic;
|
||||
ComPtr<ID3D12RootSignature> rootSignatureHeap;
|
||||
ComPtr<ID3D12RootSignature> rootSignatureHeap;
|
||||
ID3D12Device* mDevice;
|
||||
|
||||
private:
|
||||
|
@ -445,7 +445,7 @@ SpriteBatch::Impl::Impl(ID3D12Device* device, ResourceUploadBatch& upload, const
|
|||
d3dDesc.DSVFormat = psoDesc.renderTargetState.dsvFormat;
|
||||
d3dDesc.NodeMask = psoDesc.renderTargetState.nodeMask;
|
||||
d3dDesc.NumRenderTargets = psoDesc.renderTargetState.numRenderTargets;
|
||||
memcpy_s(d3dDesc.RTVFormats, sizeof(d3dDesc.RTVFormats), psoDesc.renderTargetState.rtvFormats, sizeof(DXGI_FORMAT) * D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT);
|
||||
memcpy(d3dDesc.RTVFormats, psoDesc.renderTargetState.rtvFormats, sizeof(DXGI_FORMAT) * D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT);
|
||||
d3dDesc.SampleDesc = psoDesc.renderTargetState.sampleDesc;
|
||||
d3dDesc.SampleMask = psoDesc.renderTargetState.sampleMask;
|
||||
d3dDesc.IBStripCutValue = D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_DISABLED;
|
||||
|
@ -1110,7 +1110,7 @@ void XM_CALLCONV SpriteBatch::Draw(D3D12_GPU_DESCRIPTOR_HANDLE texture,
|
|||
_Use_decl_annotations_
|
||||
void XM_CALLCONV SpriteBatch::Draw(D3D12_GPU_DESCRIPTOR_HANDLE texture,
|
||||
XMUINT2 const& textureSize,
|
||||
XMFLOAT2 const& position,
|
||||
XMFLOAT2 const& position,
|
||||
RECT const* sourceRectangle,
|
||||
FXMVECTOR color,
|
||||
float rotation,
|
||||
|
@ -1128,7 +1128,7 @@ void XM_CALLCONV SpriteBatch::Draw(D3D12_GPU_DESCRIPTOR_HANDLE texture,
|
|||
|
||||
|
||||
_Use_decl_annotations_
|
||||
void XM_CALLCONV SpriteBatch::Draw(D3D12_GPU_DESCRIPTOR_HANDLE texture,
|
||||
void XM_CALLCONV SpriteBatch::Draw(D3D12_GPU_DESCRIPTOR_HANDLE texture,
|
||||
XMUINT2 const& textureSize,
|
||||
XMFLOAT2 const& position,
|
||||
RECT const* sourceRectangle,
|
||||
|
@ -1158,7 +1158,7 @@ void XM_CALLCONV SpriteBatch::Draw(D3D12_GPU_DESCRIPTOR_HANDLE texture, XMUINT2
|
|||
_Use_decl_annotations_
|
||||
void XM_CALLCONV SpriteBatch::Draw(D3D12_GPU_DESCRIPTOR_HANDLE texture,
|
||||
XMUINT2 const& textureSize,
|
||||
FXMVECTOR position,
|
||||
FXMVECTOR position,
|
||||
RECT const* sourceRectangle,
|
||||
FXMVECTOR color,
|
||||
float rotation,
|
||||
|
@ -1199,7 +1199,7 @@ void XM_CALLCONV SpriteBatch::Draw(D3D12_GPU_DESCRIPTOR_HANDLE texture,
|
|||
}
|
||||
|
||||
|
||||
void XM_CALLCONV SpriteBatch::Draw(D3D12_GPU_DESCRIPTOR_HANDLE texture,
|
||||
void XM_CALLCONV SpriteBatch::Draw(D3D12_GPU_DESCRIPTOR_HANDLE texture,
|
||||
XMUINT2 const& textureSize,
|
||||
RECT const& destinationRectangle,
|
||||
FXMVECTOR color)
|
||||
|
@ -1217,8 +1217,8 @@ void XM_CALLCONV SpriteBatch::Draw(D3D12_GPU_DESCRIPTOR_HANDLE texture,
|
|||
RECT const* sourceRectangle,
|
||||
FXMVECTOR color,
|
||||
float rotation,
|
||||
XMFLOAT2 const& origin,
|
||||
SpriteEffects effects,
|
||||
XMFLOAT2 const& origin,
|
||||
SpriteEffects effects,
|
||||
float layerDepth)
|
||||
{
|
||||
XMVECTOR destination = LoadRect(&destinationRectangle); // x, y, w, h
|
||||
|
|
Загрузка…
Ссылка в новой задаче