mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Common: Add alignment header
Gets rid of duplicated alignment code.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// This file is under the public domain.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
namespace Common
|
||||
{
|
||||
template <typename T>
|
||||
constexpr T AlignUp(T value, size_t size)
|
||||
{
|
||||
static_assert(std::is_unsigned<T>(), "T must be an unsigned value.");
|
||||
return static_cast<T>(value + (size - value % size) % size);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
constexpr T AlignDown(T value, size_t size)
|
||||
{
|
||||
static_assert(std::is_unsigned<T>(), "T must be an unsigned value.");
|
||||
return static_cast<T>(value - value % size);
|
||||
}
|
||||
|
||||
} // namespace Common
|
||||
@@ -7,10 +7,10 @@
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/Arm64Emitter.h"
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/MathUtil.h"
|
||||
|
||||
namespace Arm64Gen
|
||||
{
|
||||
@@ -2079,14 +2079,14 @@ bool ARM64XEmitter::MOVI2R2(ARM64Reg Rd, u64 imm1, u64 imm2)
|
||||
|
||||
void ARM64XEmitter::ABI_PushRegisters(BitSet32 registers)
|
||||
{
|
||||
int num_regs = registers.Count();
|
||||
unsigned int num_regs = registers.Count();
|
||||
|
||||
if (num_regs % 2)
|
||||
{
|
||||
bool first = true;
|
||||
|
||||
// Stack is required to be quad-word aligned.
|
||||
u32 stack_size = ROUND_UP(num_regs * 8, 16);
|
||||
u32 stack_size = Common::AlignUp(num_regs * 8, 16);
|
||||
u32 current_offset = 0;
|
||||
std::vector<ARM64Reg> reg_pair;
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Align.h" />
|
||||
<ClInclude Include="Analytics.h" />
|
||||
<ClInclude Include="Assert.h" />
|
||||
<ClInclude Include="Atomic.h" />
|
||||
@@ -211,4 +212,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Align.h" />
|
||||
<ClInclude Include="Atomic.h" />
|
||||
<ClInclude Include="Atomic_GCC.h" />
|
||||
<ClInclude Include="Atomic_Win32.h" />
|
||||
@@ -293,4 +294,4 @@
|
||||
<ItemGroup>
|
||||
<Natvis Include="BitField.natvis" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -180,9 +180,6 @@ struct Rectangle
|
||||
|
||||
float MathFloatVectorSum(const std::vector<float>&);
|
||||
|
||||
#define ROUND_UP(x, a) (((x) + (a)-1) & ~((a)-1))
|
||||
#define ROUND_DOWN(x, a) ((x) & ~((a)-1))
|
||||
|
||||
// Rounds down. 0 -> undefined
|
||||
inline int IntLog2(u64 val)
|
||||
{
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/CommonPaths.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/MathUtil.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
@@ -72,7 +72,7 @@ void CBoot::Load_FST(bool _bIsWii)
|
||||
volume.ReadSwapped(0x0428, &fst_size, _bIsWii);
|
||||
volume.ReadSwapped(0x042c, &max_fst_size, _bIsWii);
|
||||
|
||||
u32 arena_high = ROUND_DOWN(0x817FFFFF - (max_fst_size << shift), 0x20);
|
||||
u32 arena_high = Common::AlignDown(0x817FFFFF - (max_fst_size << shift), 0x20);
|
||||
Memory::Write_U32(arena_high, 0x00000034);
|
||||
|
||||
// load FST
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
#include "AudioCommon/AudioCommon.h"
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/ChunkFile.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/MathUtil.h"
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
@@ -1241,7 +1241,7 @@ u64 SimulateDiscReadTime(u64 offset, u32 length)
|
||||
}
|
||||
}
|
||||
|
||||
s_last_read_offset = ROUND_DOWN(offset + length - 2048, 2048);
|
||||
s_last_read_offset = Common::AlignDown(offset + length - 2048, 2048);
|
||||
|
||||
return ticks_until_completion;
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/CommonFuncs.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Crypto/ec.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/MathUtil.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/NandPaths.h"
|
||||
#include "Common/StringUtil.h"
|
||||
@@ -345,7 +345,7 @@ void CWiiSaveCrypted::ImportWiiSaveFiles()
|
||||
if (file_hdr_tmp.type == 1)
|
||||
{
|
||||
file_size = Common::swap32(file_hdr_tmp.size);
|
||||
u32 file_size_rounded = ROUND_UP(file_size, BLOCK_SZ);
|
||||
u32 file_size_rounded = Common::AlignUp(file_size, BLOCK_SZ);
|
||||
std::vector<u8> file_data(file_size_rounded);
|
||||
std::vector<u8> file_data_enc(file_size_rounded);
|
||||
|
||||
@@ -394,7 +394,7 @@ void CWiiSaveCrypted::ExportWiiSaveFiles()
|
||||
file_hdr_tmp.type = 1;
|
||||
}
|
||||
|
||||
u32 file_size_rounded = ROUND_UP(file_size, BLOCK_SZ);
|
||||
u32 file_size_rounded = Common::AlignUp(file_size, BLOCK_SZ);
|
||||
file_hdr_tmp.magic = Common::swap32(FILE_HDR_MAGIC);
|
||||
file_hdr_tmp.size = Common::swap32(file_size);
|
||||
file_hdr_tmp.Permissions = 0x3c;
|
||||
@@ -630,7 +630,7 @@ void CWiiSaveCrypted::ScanForFiles(const std::string& save_directory,
|
||||
else
|
||||
{
|
||||
file_list.push_back(elem.physicalName);
|
||||
size += ROUND_UP(elem.size, BLOCK_SZ);
|
||||
size += static_cast<u32>(Common::AlignUp(elem.size, BLOCK_SZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/CommonFuncs.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/MathUtil.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/NandPaths.h"
|
||||
#include "Common/StringUtil.h"
|
||||
@@ -264,7 +264,7 @@ void CNANDContentLoader::InitializeContentEntries(const std::vector<u8>& tmd,
|
||||
|
||||
if (m_IsWAD)
|
||||
{
|
||||
u32 rounded_size = ROUND_UP(content.m_Size, 0x40);
|
||||
u32 rounded_size = Common::AlignUp(content.m_Size, 0x40);
|
||||
|
||||
iv.fill(0);
|
||||
std::copy(&tmd[entry_offset + 0x01E8], &tmd[entry_offset + 0x01E8 + 2], iv.begin());
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/CommonPaths.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/MathUtil.h"
|
||||
#include "DiscIO/Blob.h"
|
||||
#include "DiscIO/Enums.h"
|
||||
#include "DiscIO/FileMonitor.h"
|
||||
@@ -308,7 +308,7 @@ bool CVolumeDirectory::SetApploader(const std::string& _rApploader)
|
||||
std::copy(data.begin(), data.end(), m_apploader.begin());
|
||||
|
||||
// 32byte aligned (plus 0x20 padding)
|
||||
m_dol_address = ROUND_UP(APPLOADER_ADDRESS + m_apploader.size() + 0x20, 0x20ull);
|
||||
m_dol_address = Common::AlignUp(APPLOADER_ADDRESS + m_apploader.size() + 0x20, 0x20ull);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -332,7 +332,7 @@ void CVolumeDirectory::SetDOL(const std::string& rDOL)
|
||||
Write32((u32)(m_dol_address >> m_addressShift), 0x0420, &m_diskHeader);
|
||||
|
||||
// 32byte aligned (plus 0x20 padding)
|
||||
m_fst_address = ROUND_UP(m_dol_address + m_DOL.size() + 0x20, 0x20ull);
|
||||
m_fst_address = Common::AlignUp(m_dol_address + m_DOL.size() + 0x20, 0x20ull);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ void CVolumeDirectory::BuildFST()
|
||||
m_fst_address = APPLOADER_ADDRESS + 0x2000;
|
||||
|
||||
// 4 byte aligned start of data on disk
|
||||
m_dataStartAddress = ROUND_UP(m_fst_address + m_FSTData.size(), 0x8000ull);
|
||||
m_dataStartAddress = Common::AlignUp(m_fst_address + m_FSTData.size(), 0x8000ull);
|
||||
u64 curDataAddress = m_dataStartAddress;
|
||||
|
||||
u32 fstOffset = 0; // Offset within FST data
|
||||
@@ -470,7 +470,7 @@ void CVolumeDirectory::WriteEntry(const File::FSTEntry& entry, u32& fstOffset, u
|
||||
m_virtualDisk.emplace(dataOffset, entry.physicalName);
|
||||
|
||||
// 4 byte aligned
|
||||
dataOffset = ROUND_UP(dataOffset + std::max<u64>(entry.size, 1ull), 0x8000ull);
|
||||
dataOffset = Common::AlignUp(dataOffset + std::max<u64>(entry.size, 1ull), 0x8000ull);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/MathUtil.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "DiscIO/Blob.h"
|
||||
@@ -20,8 +20,6 @@
|
||||
#include "DiscIO/Volume.h"
|
||||
#include "DiscIO/VolumeWad.h"
|
||||
|
||||
#define ALIGN_40(x) ROUND_UP(Common::swap32(x), 0x40)
|
||||
|
||||
namespace DiscIO
|
||||
{
|
||||
CVolumeWAD::CVolumeWAD(std::unique_ptr<IBlobReader> reader)
|
||||
@@ -35,9 +33,13 @@ CVolumeWAD::CVolumeWAD(std::unique_ptr<IBlobReader> reader)
|
||||
Read(0x14, 4, (u8*)&m_tmd_size);
|
||||
Read(0x18, 4, (u8*)&m_data_size);
|
||||
|
||||
m_offset = ALIGN_40(m_hdr_size) + ALIGN_40(m_cert_size);
|
||||
m_tmd_offset = ALIGN_40(m_hdr_size) + ALIGN_40(m_cert_size) + ALIGN_40(m_tick_size);
|
||||
m_opening_bnr_offset = m_tmd_offset + ALIGN_40(m_tmd_size) + ALIGN_40(m_data_size);
|
||||
m_offset = Common::AlignUp(Common::swap32(m_hdr_size), 0x40) +
|
||||
Common::AlignUp(Common::swap32(m_cert_size), 0x40);
|
||||
m_tmd_offset = Common::AlignUp(Common::swap32(m_hdr_size), 0x40) +
|
||||
Common::AlignUp(Common::swap32(m_cert_size), 0x40) +
|
||||
Common::AlignUp(Common::swap32(m_tick_size), 0x40);
|
||||
m_opening_bnr_offset = m_tmd_offset + Common::AlignUp(Common::swap32(m_tmd_size), 0x40) +
|
||||
Common::AlignUp(Common::swap32(m_data_size), 0x40);
|
||||
}
|
||||
|
||||
CVolumeWAD::~CVolumeWAD()
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/CommonFuncs.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
@@ -22,11 +23,6 @@ static const u64 WII_SECTOR_SIZE = 0x8000;
|
||||
static const u64 WII_SECTOR_COUNT = 143432 * 2;
|
||||
static const u64 WII_DISC_HEADER_SIZE = 256;
|
||||
|
||||
static inline u64 align(u64 value, u64 bounds)
|
||||
{
|
||||
return (value + (bounds - 1)) & (~(bounds - 1));
|
||||
}
|
||||
|
||||
WbfsFileReader::WbfsFileReader(const std::string& filename)
|
||||
: m_total_files(0), m_size(0), m_good(true)
|
||||
{
|
||||
@@ -104,7 +100,7 @@ bool WbfsFileReader::ReadHeader()
|
||||
m_blocks_per_disc =
|
||||
(WII_SECTOR_COUNT * WII_SECTOR_SIZE + m_wbfs_sector_size - 1) / m_wbfs_sector_size;
|
||||
m_disc_info_size =
|
||||
align(WII_DISC_HEADER_SIZE + m_blocks_per_disc * sizeof(u16), m_hd_sector_size);
|
||||
Common::AlignUp(WII_DISC_HEADER_SIZE + m_blocks_per_disc * sizeof(u16), m_hd_sector_size);
|
||||
|
||||
return m_header.disc_table[0] != 0;
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/MathUtil.h"
|
||||
#include "DiscIO/Blob.h"
|
||||
#include "DiscIO/WiiWad.h"
|
||||
|
||||
@@ -87,15 +87,15 @@ bool WiiWAD::ParseWAD(IBlobReader& reader)
|
||||
|
||||
u32 offset = 0x40;
|
||||
m_certificate_chain = CreateWADEntry(reader, certificate_chain_size, offset);
|
||||
offset += ROUND_UP(certificate_chain_size, 0x40);
|
||||
offset += Common::AlignUp(certificate_chain_size, 0x40);
|
||||
m_ticket = CreateWADEntry(reader, ticket_size, offset);
|
||||
offset += ROUND_UP(ticket_size, 0x40);
|
||||
offset += Common::AlignUp(ticket_size, 0x40);
|
||||
m_tmd = CreateWADEntry(reader, tmd_size, offset);
|
||||
offset += ROUND_UP(tmd_size, 0x40);
|
||||
offset += Common::AlignUp(tmd_size, 0x40);
|
||||
m_data_app = CreateWADEntry(reader, data_app_size, offset);
|
||||
offset += ROUND_UP(data_app_size, 0x40);
|
||||
offset += Common::AlignUp(data_app_size, 0x40);
|
||||
m_footer = CreateWADEntry(reader, footer_size, offset);
|
||||
offset += ROUND_UP(footer_size, 0x40);
|
||||
offset += Common::AlignUp(footer_size, 0x40);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "VideoBackends/D3D/D3DBase.h"
|
||||
#include "VideoBackends/D3D/D3DShader.h"
|
||||
#include "VideoBackends/D3D/D3DState.h"
|
||||
@@ -22,7 +23,7 @@ namespace D3D
|
||||
class UtilVertexBuffer
|
||||
{
|
||||
public:
|
||||
UtilVertexBuffer(int size) : buf(nullptr), offset(0), max_size(size)
|
||||
UtilVertexBuffer(unsigned int size) : max_size(size)
|
||||
{
|
||||
D3D11_BUFFER_DESC desc = CD3D11_BUFFER_DESC(max_size, D3D11_BIND_VERTEX_BUFFER,
|
||||
D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
|
||||
@@ -31,7 +32,7 @@ public:
|
||||
~UtilVertexBuffer() { buf->Release(); }
|
||||
int GetSize() const { return max_size; }
|
||||
// returns vertex offset to the new data
|
||||
int AppendData(void* data, int size, int vertex_size)
|
||||
int AppendData(void* data, unsigned int size, unsigned int vertex_size)
|
||||
{
|
||||
D3D11_MAPPED_SUBRESOURCE map;
|
||||
if (offset + size >= max_size)
|
||||
@@ -47,8 +48,7 @@ public:
|
||||
{
|
||||
context->Map(buf, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &map);
|
||||
}
|
||||
offset = ((offset + vertex_size - 1) / vertex_size) *
|
||||
vertex_size; // align offset to vertex_size bytes
|
||||
offset = Common::AlignUp(offset, vertex_size);
|
||||
memcpy((u8*)map.pData + offset, data, size);
|
||||
context->Unmap(buf, 0);
|
||||
|
||||
@@ -56,13 +56,12 @@ public:
|
||||
return (offset - size) / vertex_size;
|
||||
}
|
||||
|
||||
int BeginAppendData(void** write_ptr, int size, int vertex_size)
|
||||
int BeginAppendData(void** write_ptr, unsigned int size, unsigned int vertex_size)
|
||||
{
|
||||
_dbg_assert_(VIDEO, size < max_size);
|
||||
|
||||
D3D11_MAPPED_SUBRESOURCE map;
|
||||
int aligned_offset = ((offset + vertex_size - 1) / vertex_size) *
|
||||
vertex_size; // align offset to vertex_size bytes
|
||||
unsigned int aligned_offset = Common::AlignUp(offset, vertex_size);
|
||||
if (aligned_offset + size > max_size)
|
||||
{
|
||||
// wrap buffer around and notify observers
|
||||
@@ -87,9 +86,9 @@ public:
|
||||
void AddWrapObserver(bool* observer) { observers.push_back(observer); }
|
||||
inline ID3D11Buffer*& GetBuffer() { return buf; }
|
||||
private:
|
||||
ID3D11Buffer* buf;
|
||||
int offset;
|
||||
int max_size;
|
||||
ID3D11Buffer* buf = nullptr;
|
||||
unsigned int offset = 0;
|
||||
unsigned int max_size;
|
||||
|
||||
std::list<bool*> observers;
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/LinearDiskCache.h"
|
||||
#include "Common/StringUtil.h"
|
||||
@@ -135,7 +136,8 @@ const char copy_shader_code[] = {
|
||||
|
||||
void GeometryShaderCache::Init()
|
||||
{
|
||||
unsigned int gbsize = ROUND_UP(sizeof(GeometryShaderConstants), 16); // must be a multiple of 16
|
||||
unsigned int gbsize = Common::AlignUp(static_cast<unsigned int>(sizeof(GeometryShaderConstants)),
|
||||
16); // must be a multiple of 16
|
||||
D3D11_BUFFER_DESC gbdesc = CD3D11_BUFFER_DESC(gbsize, D3D11_BIND_CONSTANT_BUFFER,
|
||||
D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
|
||||
HRESULT hr = D3D::device->CreateBuffer(&gbdesc, nullptr, &gscbuf);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/LinearDiskCache.h"
|
||||
@@ -457,7 +458,8 @@ public:
|
||||
|
||||
void PixelShaderCache::Init()
|
||||
{
|
||||
unsigned int cbsize = ROUND_UP(sizeof(PixelShaderConstants), 16); // must be a multiple of 16
|
||||
unsigned int cbsize = Common::AlignUp(static_cast<unsigned int>(sizeof(PixelShaderConstants)),
|
||||
16); // must be a multiple of 16
|
||||
D3D11_BUFFER_DESC cbdesc = CD3D11_BUFFER_DESC(cbsize, D3D11_BIND_CONSTANT_BUFFER,
|
||||
D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
|
||||
D3D::device->CreateBuffer(&cbdesc, nullptr, &pscbuf);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/LinearDiskCache.h"
|
||||
@@ -122,7 +123,8 @@ void VertexShaderCache::Init()
|
||||
{"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},
|
||||
};
|
||||
|
||||
unsigned int cbsize = ROUND_UP(sizeof(VertexShaderConstants), 16); // must be a multiple of 16
|
||||
unsigned int cbsize = Common::AlignUp(static_cast<unsigned int>(sizeof(VertexShaderConstants)),
|
||||
16); // must be a multiple of 16
|
||||
D3D11_BUFFER_DESC cbdesc = CD3D11_BUFFER_DESC(cbsize, D3D11_BIND_CONSTANT_BUFFER,
|
||||
D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
|
||||
HRESULT hr = D3D::device->CreateBuffer(&cbdesc, nullptr, &vscbuf);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Common/Align.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "VideoBackends/D3D12/D3DBase.h"
|
||||
@@ -34,7 +35,7 @@ void ReplaceRGBATexture2D(ID3D12Resource* texture12, const u8* buffer, unsigned
|
||||
D3D12_RESOURCE_STATES current_resource_state)
|
||||
{
|
||||
const unsigned int upload_size =
|
||||
AlignValue(src_pitch, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT) * height;
|
||||
Common::AlignUp(src_pitch, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT) * height;
|
||||
|
||||
ID3D12Resource* upload_buffer = nullptr;
|
||||
size_t upload_buffer_offset = 0;
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/Align.h"
|
||||
|
||||
#include "VideoBackends/D3D12/D3DBase.h"
|
||||
#include "VideoBackends/D3D12/D3DCommandListManager.h"
|
||||
#include "VideoBackends/D3D12/D3DDescriptorHeapManager.h"
|
||||
@@ -254,8 +256,9 @@ int CD3DFont::Init()
|
||||
ID3D12Resource* temporaryFontTextureUploadBuffer;
|
||||
CheckHR(D3D::device12->CreateCommittedResource(
|
||||
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD), D3D12_HEAP_FLAG_NONE,
|
||||
&CD3DX12_RESOURCE_DESC::Buffer(
|
||||
AlignValue(m_tex_width * 4, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT) * m_tex_height),
|
||||
&CD3DX12_RESOURCE_DESC::Buffer(Common::AlignUp(static_cast<unsigned int>(m_tex_width) * 4,
|
||||
D3D12_TEXTURE_DATA_PITCH_ALIGNMENT) *
|
||||
m_tex_height),
|
||||
D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&temporaryFontTextureUploadBuffer)));
|
||||
|
||||
D3D12_SUBRESOURCE_DATA subresource_data_dest = {
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/MathUtil.h"
|
||||
#include "VideoBackends/D3D12/D3DState.h"
|
||||
#include "VideoBackends/D3D12/D3DStreamBuffer.h"
|
||||
|
||||
@@ -19,11 +18,6 @@ extern StateCache gx_state_cache;
|
||||
|
||||
namespace D3D
|
||||
{
|
||||
constexpr unsigned int AlignValue(unsigned int value, unsigned int alignment)
|
||||
{
|
||||
return (value + (alignment - 1)) & ~(alignment - 1);
|
||||
}
|
||||
|
||||
void ResourceBarrier(ID3D12GraphicsCommandList* command_list, ID3D12Resource* resource,
|
||||
D3D12_RESOURCE_STATES state_before, D3D12_RESOURCE_STATES state_after,
|
||||
UINT subresource);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user