mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 21:32:50 +00:00
d3d12: Use __mm_stream_si128 to send texture/constants data
This commit is contained in:
parent
12fc6e6145
commit
bd68d382bd
27
rpcs3/Emu/RSX/D3D12/D3D12.h
Normal file
27
rpcs3/Emu/RSX/D3D12/D3D12.h
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
#if defined(DX12_SUPPORT)
|
||||
|
||||
#include <d3d12.h>
|
||||
|
||||
inline
|
||||
void check(HRESULT hr)
|
||||
{
|
||||
if (hr != 0)
|
||||
abort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send data to dst pointer without polluting cache.
|
||||
* Usefull to write to mapped memory from upload heap.
|
||||
*/
|
||||
inline
|
||||
void streamToBuffer(void* dst, void* src, size_t sizeInBytes)
|
||||
{
|
||||
for (unsigned i = 0; i < sizeInBytes / 16; i++)
|
||||
{
|
||||
__m128i *srcPtr = (__m128i*) ((char*)src + i * 16);
|
||||
_mm_stream_si128((__m128i*)((char*)dst + i * 16), *srcPtr);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -15,13 +15,6 @@ void SetGetD3DGSFrameCallback(GetGSFrameCb2 value)
|
||||
GetGSFrame = value;
|
||||
}
|
||||
|
||||
static void check(HRESULT hr)
|
||||
{
|
||||
if (hr != 0)
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
void D3D12GSRender::ResourceStorage::Reset()
|
||||
{
|
||||
m_currentVertexBuffersHeapOffset = 0;
|
||||
@ -622,7 +615,7 @@ void D3D12GSRender::setScaleOffset()
|
||||
|
||||
void *scaleOffsetMap;
|
||||
check(scaleOffsetBuffer->Map(0, nullptr, &scaleOffsetMap));
|
||||
memcpy((char*)scaleOffsetMap, scaleOffsetMat, 16 * sizeof(float));
|
||||
streamToBuffer(scaleOffsetMap, scaleOffsetMat, 16 * sizeof(float));
|
||||
scaleOffsetBuffer->Unmap(0, nullptr);
|
||||
|
||||
D3D12_CONSTANT_BUFFER_VIEW_DESC constantBufferViewDesc = {};
|
||||
@ -669,7 +662,7 @@ void D3D12GSRender::FillVertexShaderConstantsBuffer()
|
||||
|
||||
void *constantsBufferMap;
|
||||
check(constantsBuffer->Map(0, nullptr, &constantsBufferMap));
|
||||
memcpy(constantsBufferMap, vertexConstantShadowCopy, 512 * 4 * sizeof(float));
|
||||
streamToBuffer(constantsBufferMap, vertexConstantShadowCopy, 512 * 4 * sizeof(float));
|
||||
constantsBuffer->Unmap(0, nullptr);
|
||||
|
||||
D3D12_CONSTANT_BUFFER_VIEW_DESC constantBufferViewDesc = {};
|
||||
@ -769,7 +762,7 @@ void D3D12GSRender::FillPixelShaderConstantsBuffer()
|
||||
vector[3] = c3;
|
||||
}
|
||||
|
||||
memcpy((char*)constantsBufferMap + offset, vector, 4 * sizeof(u32));
|
||||
streamToBuffer((char*)constantsBufferMap + offset, vector, 4 * sizeof(u32));
|
||||
offset += 4 * sizeof(u32);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#if defined(DX12_SUPPORT)
|
||||
|
||||
#include <d3d12.h>
|
||||
#include "D3D12.h"
|
||||
#include "rpcs3/Ini.h"
|
||||
#include "Utilities/rPlatform.h" // only for rImage
|
||||
#include "Utilities/File.h"
|
||||
|
@ -3,12 +3,6 @@
|
||||
#include "D3D12GSRender.h"
|
||||
// For clarity this code deals with texture but belongs to D3D12GSRender class
|
||||
|
||||
static void check(HRESULT hr)
|
||||
{
|
||||
if (hr != 0)
|
||||
abort();
|
||||
}
|
||||
|
||||
size_t D3D12GSRender::UploadTextures()
|
||||
{
|
||||
size_t usedTexture = 0;
|
||||
@ -67,9 +61,7 @@ size_t D3D12GSRender::UploadTextures()
|
||||
rowPitch = (rowPitch + 255) & ~255;
|
||||
// Upload with correct rowpitch
|
||||
for (unsigned row = 0; row < m_textures[i].GetHeight(); row++)
|
||||
{
|
||||
memcpy((char*)textureData + row * rowPitch, pixels + row * m_textures[i].m_pitch, m_textures[i].m_pitch);
|
||||
}
|
||||
streamToBuffer((char*)textureData + row * rowPitch, (char*)pixels + row * m_textures[i].m_pitch, m_textures[i].m_pitch);
|
||||
Texture->Unmap(0, nullptr);
|
||||
|
||||
D3D12_RESOURCE_DESC vramTextureDesc = {};
|
||||
|
@ -505,6 +505,7 @@
|
||||
<ClInclude Include="Emu\RSX\Common\ProgramStateCache.h" />
|
||||
<ClInclude Include="Emu\RSX\Common\ShaderParam.h" />
|
||||
<ClInclude Include="Emu\RSX\Common\VertexProgramDecompiler.h" />
|
||||
<ClInclude Include="Emu\RSX\D3D12\D3D12.h" />
|
||||
<ClInclude Include="Emu\RSX\D3D12\D3D12Buffer.h" />
|
||||
<ClInclude Include="Emu\RSX\D3D12\D3D12FragmentProgramDecompiler.h" />
|
||||
<ClInclude Include="Emu\RSX\D3D12\D3D12GSRender.h" />
|
||||
|
@ -1873,5 +1873,8 @@
|
||||
<ClInclude Include="Emu\RSX\D3D12\D3D12Texture.h">
|
||||
<Filter>Emu\GPU\RSX\D3D12</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Emu\RSX\D3D12\D3D12.h">
|
||||
<Filter>Emu\GPU\RSX\D3D12</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
x
Reference in New Issue
Block a user