mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 12:09:36 +00:00
Add FreeType, progress to title screen
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "GpAppEnvironment.h"
|
||||
#include "GpFiberStarter.h"
|
||||
#include "GpAppInterface.h"
|
||||
#include "GpFontHandlerFactory.h"
|
||||
#include "GpPLGlueAudioDriver.h"
|
||||
#include "GpPLGlueDisplayDriver.h"
|
||||
#include "GpFiber.h"
|
||||
@@ -12,6 +13,7 @@ GpAppEnvironment::GpAppEnvironment()
|
||||
: m_applicationState(ApplicationState_NotStarted)
|
||||
, m_displayDriver(nullptr)
|
||||
, m_audioDriver(nullptr)
|
||||
, m_fontHandler(nullptr)
|
||||
, m_applicationFiber(nullptr)
|
||||
, m_vosFiber(nullptr)
|
||||
, m_suspendCallID(PortabilityLayer::HostSuspendCallID_Unknown)
|
||||
@@ -63,7 +65,7 @@ void GpAppEnvironment::Tick(GpFiber *vosFiber)
|
||||
}
|
||||
break;
|
||||
case ApplicationState_TimedSuspend:
|
||||
if (m_delaySuspendTicks <= 1)
|
||||
if (m_delaySuspendTicks == 0)
|
||||
m_applicationState = ApplicationState_Running;
|
||||
else
|
||||
{
|
||||
@@ -78,6 +80,11 @@ void GpAppEnvironment::Tick(GpFiber *vosFiber)
|
||||
}
|
||||
}
|
||||
|
||||
void GpAppEnvironment::Render()
|
||||
{
|
||||
GpAppInterface_Get()->PL_Render(m_displayDriver);
|
||||
}
|
||||
|
||||
void GpAppEnvironment::SetDisplayDriver(IGpDisplayDriver *displayDriver)
|
||||
{
|
||||
m_displayDriver = displayDriver;
|
||||
@@ -88,6 +95,11 @@ void GpAppEnvironment::SetAudioDriver(IGpAudioDriver *audioDriver)
|
||||
m_audioDriver = audioDriver;
|
||||
}
|
||||
|
||||
void GpAppEnvironment::SetFontHandler(PortabilityLayer::HostFontHandler *fontHandler)
|
||||
{
|
||||
m_fontHandler = fontHandler;
|
||||
}
|
||||
|
||||
void GpAppEnvironment::StaticAppThreadFunc(void *context)
|
||||
{
|
||||
static_cast<GpAppEnvironment*>(context)->AppThreadFunc();
|
||||
@@ -104,6 +116,9 @@ void GpAppEnvironment::InitializeApplicationState()
|
||||
GpAppInterface_Get()->PL_HostAudioDriver_SetInstance(GpPLGlueAudioDriver::GetInstance());
|
||||
GpAppInterface_Get()->PL_InstallHostSuspendHook(GpAppEnvironment::StaticSuspendHookFunc, this);
|
||||
|
||||
GpAppInterface_Get()->PL_HostFontHandler_SetInstance(m_fontHandler);
|
||||
GpAppInterface_Get()->PL_HostVOSEventQueue_SetInstance(&m_vosEventQueue);
|
||||
|
||||
SynchronizeState();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "GpVOSEventQueue.h"
|
||||
#include "HostSuspendCallID.h"
|
||||
|
||||
#include <stdint.h>
|
||||
@@ -7,10 +8,12 @@
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
union HostSuspendCallArgument;
|
||||
class HostFontHandler;
|
||||
class HostVOSEventQueue;
|
||||
}
|
||||
|
||||
class IGpDisplayDriver;
|
||||
class IGpAudioDriver;
|
||||
struct IGpDisplayDriver;
|
||||
struct IGpAudioDriver;
|
||||
class GpFiber;
|
||||
|
||||
class GpAppEnvironment
|
||||
@@ -22,8 +25,11 @@ public:
|
||||
void Init();
|
||||
|
||||
void Tick(GpFiber *vosFiber);
|
||||
void Render();
|
||||
|
||||
void SetDisplayDriver(IGpDisplayDriver *displayDriver);
|
||||
void SetAudioDriver(IGpAudioDriver *audioDriver);
|
||||
void SetFontHandler(PortabilityLayer::HostFontHandler *fontHandler);
|
||||
|
||||
private:
|
||||
enum ApplicationState
|
||||
@@ -47,6 +53,8 @@ private:
|
||||
ApplicationState m_applicationState;
|
||||
IGpDisplayDriver *m_displayDriver;
|
||||
IGpAudioDriver *m_audioDriver;
|
||||
PortabilityLayer::HostFontHandler *m_fontHandler;
|
||||
GpVOSEventQueue m_vosEventQueue;
|
||||
GpFiber *m_applicationFiber;
|
||||
GpFiber *m_vosFiber;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "EGpAudioDriverType.h"
|
||||
|
||||
class IGpAudioDriver;
|
||||
struct IGpAudioDriver;
|
||||
struct GpAudioDriverProperties;
|
||||
|
||||
class GpAudioDriverFactory
|
||||
|
||||
120
GpD3D/GpComPtr.h
Normal file
120
GpD3D/GpComPtr.h
Normal file
@@ -0,0 +1,120 @@
|
||||
#pragma once
|
||||
|
||||
template<class T>
|
||||
class GpComPtr final
|
||||
{
|
||||
public:
|
||||
GpComPtr();
|
||||
const GpComPtr(const GpComPtr<T> &other);
|
||||
explicit GpComPtr(T *ptr);
|
||||
~GpComPtr();
|
||||
|
||||
GpComPtr<T> &operator=(const GpComPtr<T> &other);
|
||||
GpComPtr<T> &operator=(T *other);
|
||||
|
||||
bool operator==(const GpComPtr<T> &other) const;
|
||||
bool operator!=(const GpComPtr<T> &other) const;
|
||||
|
||||
bool operator==(const T *other) const;
|
||||
bool operator!=(const T *other) const;
|
||||
|
||||
operator T*() const;
|
||||
T *operator->() const;
|
||||
|
||||
T **GetMutablePtr();
|
||||
|
||||
private:
|
||||
T *m_ptr;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
inline GpComPtr<T>::GpComPtr()
|
||||
: m_ptr(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline GpComPtr<T>::GpComPtr(const GpComPtr<T> &other)
|
||||
: m_ptr(other.m_ptr)
|
||||
{
|
||||
if (m_ptr)
|
||||
m_ptr->AddRef();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline GpComPtr<T>::GpComPtr(T *ptr)
|
||||
: m_ptr(ptr)
|
||||
{
|
||||
if (ptr)
|
||||
ptr->AddRef();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline GpComPtr<T>::~GpComPtr()
|
||||
{
|
||||
if (m_ptr)
|
||||
m_ptr->Release();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline GpComPtr<T> &GpComPtr<T>::operator=(const GpComPtr<T> &other)
|
||||
{
|
||||
(*this) = other.m_ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline GpComPtr<T> &GpComPtr<T>::operator=(T *other)
|
||||
{
|
||||
if (other)
|
||||
other->AddRef();
|
||||
|
||||
if (m_ptr)
|
||||
m_ptr->Release();
|
||||
|
||||
m_ptr = other;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool GpComPtr<T>::operator==(const GpComPtr<T> &other) const
|
||||
{
|
||||
return m_ptr == other.m_ptr;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool GpComPtr<T>::operator!=(const GpComPtr<T> &other) const
|
||||
{
|
||||
return !((*this) == other);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool GpComPtr<T>::operator==(const T *other) const
|
||||
{
|
||||
return m_ptr == other;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool GpComPtr<T>::operator!=(const T *other) const
|
||||
{
|
||||
return !((*this) == other);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
T **GpComPtr<T>::GetMutablePtr()
|
||||
{
|
||||
return &m_ptr;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline GpComPtr<T>::operator T*() const
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T *GpComPtr<T>::operator->() const
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
@@ -62,6 +62,8 @@
|
||||
<Import Project="..\Common.props" />
|
||||
<Import Project="..\GpCommon.props" />
|
||||
<Import Project="..\GpMainApp.props" />
|
||||
<Import Project="..\FreeTypePublic.props" />
|
||||
<Import Project="..\FreeTypeImport.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
@@ -69,6 +71,8 @@
|
||||
<Import Project="..\Common.props" />
|
||||
<Import Project="..\GpCommon.props" />
|
||||
<Import Project="..\GpMainApp.props" />
|
||||
<Import Project="..\FreeTypePublic.props" />
|
||||
<Import Project="..\FreeTypeImport.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
@@ -76,6 +80,8 @@
|
||||
<Import Project="..\Common.props" />
|
||||
<Import Project="..\GpCommon.props" />
|
||||
<Import Project="..\GpMainApp.props" />
|
||||
<Import Project="..\FreeTypePublic.props" />
|
||||
<Import Project="..\FreeTypeImport.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
@@ -83,6 +89,8 @@
|
||||
<Import Project="..\Common.props" />
|
||||
<Import Project="..\GpCommon.props" />
|
||||
<Import Project="..\GpMainApp.props" />
|
||||
<Import Project="..\FreeTypePublic.props" />
|
||||
<Import Project="..\FreeTypeImport.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
@@ -139,9 +147,12 @@
|
||||
<ClCompile Include="GpAudioDriverFactory.cpp" />
|
||||
<ClCompile Include="GpDisplayDriverFactory.cpp" />
|
||||
<ClCompile Include="GpDisplayDriverFactoryD3D11.cpp" />
|
||||
<ClCompile Include="GpDisplayDriverSurfaceD3D11.cpp" />
|
||||
<ClCompile Include="GpFiber_Win32.cpp" />
|
||||
<ClCompile Include="GpFileStream_Win32.cpp" />
|
||||
<ClCompile Include="GpFileSystem_Win32.cpp" />
|
||||
<ClCompile Include="GpFontHandlerFactory.cpp" />
|
||||
<ClCompile Include="GpFontHandler_FreeType2.cpp" />
|
||||
<ClCompile Include="GpGlobalConfig.cpp" />
|
||||
<ClCompile Include="GpMain.cpp" />
|
||||
<ClCompile Include="GpMain_Win32.cpp" />
|
||||
@@ -154,24 +165,34 @@
|
||||
<ClCompile Include="GpSystemServices_Win32.cpp" />
|
||||
<ClCompile Include="GpFiberStarter_Win32.cpp" />
|
||||
<ClCompile Include="GpThreadEvent_Win32.cpp" />
|
||||
<ClCompile Include="GpVOSEventQueue.cpp" />
|
||||
<ClCompile Include="ShadersD3D11\DrawQuad15BitP_D3D11.cpp" />
|
||||
<ClCompile Include="ShadersD3D11\DrawQuadPaletteP_D3D11.cpp" />
|
||||
<ClCompile Include="ShadersD3D11\DrawQuadRGBP_D3D11.cpp" />
|
||||
<ClCompile Include="ShadersD3D11\DrawQuadV_D3D11.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\GpCommon\IGpAudioChannelCallbacks.h" />
|
||||
<ClInclude Include="..\GpCommon\IGpDisplayDriverSurface.h" />
|
||||
<ClInclude Include="EGpAudioDriverType.h" />
|
||||
<ClInclude Include="EGpDisplayDriverType.h" />
|
||||
<ClInclude Include="GpAppEnvironment.h" />
|
||||
<ClInclude Include="GpAudioDriverFactory.h" />
|
||||
<ClInclude Include="GpAudioDriverProperties.h" />
|
||||
<ClInclude Include="GpAudioDriverXAudio2.h" />
|
||||
<ClInclude Include="GpComPtr.h" />
|
||||
<ClInclude Include="GpCoreDefs.h" />
|
||||
<ClInclude Include="GpDisplayDriverD3D11.h" />
|
||||
<ClInclude Include="GpDisplayDriverFactory.h" />
|
||||
<ClInclude Include="GpDisplayDriverFactoryD3D11.h" />
|
||||
<ClInclude Include="GpDisplayDriverProperties.h" />
|
||||
<ClInclude Include="GpDisplayDriverSurfaceD3D11.h" />
|
||||
<ClInclude Include="GpFiber.h" />
|
||||
<ClInclude Include="GpFiber_Win32.h" />
|
||||
<ClInclude Include="GpFileStream_Win32.h" />
|
||||
<ClInclude Include="GpFileSystem_Win32.h" />
|
||||
<ClInclude Include="GpFontHandler_FreeType2.h" />
|
||||
<ClInclude Include="GpFontHandlerFactory.h" />
|
||||
<ClInclude Include="GpGlobalConfig.h" />
|
||||
<ClInclude Include="GpMain.h" />
|
||||
<ClInclude Include="GpMemoryBuffer.h" />
|
||||
@@ -183,12 +204,16 @@
|
||||
<ClInclude Include="GpSystemServices_Win32.h" />
|
||||
<ClInclude Include="GpFiberStarter.h" />
|
||||
<ClInclude Include="GpThreadEvent_Win32.h" />
|
||||
<ClInclude Include="GpVOSEventQueue.h" />
|
||||
<ClInclude Include="GpWindows.h" />
|
||||
<ClInclude Include="IGpAudioChannel.h" />
|
||||
<ClInclude Include="IGpAudioDriver.h" />
|
||||
<ClInclude Include="IGpDisplayDriver.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FreeType\FreeType.vcxproj">
|
||||
<Project>{487216d8-16ba-4b4c-b5bf-43feedfee03a}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\GpApp\GpApp.vcxproj">
|
||||
<Project>{6233c3f2-5781-488e-b190-4fa8836f5a77}</Project>
|
||||
</ProjectReference>
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\CompiledShaders">
|
||||
<UniqueIdentifier>{6dd6af81-4f84-4e4f-aa25-9dd4c1b53536}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="GpMain_Win32.cpp">
|
||||
@@ -72,6 +75,30 @@
|
||||
<ClCompile Include="GpThreadEvent_Win32.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GpFontHandlerFactory.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GpFontHandler_FreeType2.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GpVOSEventQueue.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GpDisplayDriverSurfaceD3D11.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ShadersD3D11\DrawQuadV_D3D11.cpp">
|
||||
<Filter>Source Files\CompiledShaders</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ShadersD3D11\DrawQuad15BitP_D3D11.cpp">
|
||||
<Filter>Source Files\CompiledShaders</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ShadersD3D11\DrawQuadPaletteP_D3D11.cpp">
|
||||
<Filter>Source Files\CompiledShaders</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ShadersD3D11\DrawQuadRGBP_D3D11.cpp">
|
||||
<Filter>Source Files\CompiledShaders</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="GpWindows.h">
|
||||
@@ -167,5 +194,23 @@
|
||||
<ClInclude Include="..\GpCommon\IGpAudioChannelCallbacks.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GpFontHandlerFactory.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GpFontHandler_FreeType2.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GpVOSEventQueue.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\GpCommon\IGpDisplayDriverSurface.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GpDisplayDriverSurfaceD3D11.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GpComPtr.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,14 +1,40 @@
|
||||
#include "GpDisplayDriverD3D11.h"
|
||||
#include "GpDisplayDriverSurfaceD3D11.h"
|
||||
#include "GpWindows.h"
|
||||
#include "GpFiber_Win32.h"
|
||||
|
||||
#include <d3d11.h>
|
||||
#include <dxgi1_2.h>
|
||||
#include <float.h>
|
||||
#include <emmintrin.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#pragma comment (lib, "d3d11.lib")
|
||||
|
||||
namespace GpBinarizedShaders
|
||||
{
|
||||
extern const unsigned char *g_drawQuadV_D3D11[2];
|
||||
extern const unsigned char *g_drawQuadPaletteP_D3D11[2];
|
||||
extern const unsigned char *g_drawQuadRGBP_D3D11[2];
|
||||
extern const unsigned char *g_drawQuad15BitP_D3D11[2];
|
||||
}
|
||||
|
||||
struct GpShaderCodeBlob
|
||||
{
|
||||
const void *m_data;
|
||||
size_t m_size;
|
||||
};
|
||||
|
||||
static GpShaderCodeBlob GetBinarizedShader(const unsigned char **shaderPointers)
|
||||
{
|
||||
GpShaderCodeBlob blob;
|
||||
blob.m_data = shaderPointers[0];
|
||||
blob.m_size = shaderPointers[1] - shaderPointers[0];
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
void DebugPrintf(const char *fmt, ...)
|
||||
{
|
||||
char buf[256];
|
||||
@@ -34,7 +60,7 @@ LRESULT CALLBACK WinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
void StartD3DForWindow(HWND hWnd, IDXGISwapChain1*& swapChain)
|
||||
void StartD3DForWindow(HWND hWnd, GpComPtr<IDXGISwapChain1>& outSwapChain, GpComPtr<ID3D11Device>& outDevice, GpComPtr<ID3D11DeviceContext>& outContext)
|
||||
{
|
||||
DXGI_SWAP_CHAIN_DESC1 swapChainDesc;
|
||||
|
||||
@@ -57,7 +83,7 @@ void StartD3DForWindow(HWND hWnd, IDXGISwapChain1*& swapChain)
|
||||
UINT flags = 0;
|
||||
const D3D_FEATURE_LEVEL featureLevels[] =
|
||||
{
|
||||
D3D_FEATURE_LEVEL_9_1
|
||||
D3D_FEATURE_LEVEL_10_0
|
||||
};
|
||||
|
||||
flags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||
@@ -79,11 +105,230 @@ void StartD3DForWindow(HWND hWnd, IDXGISwapChain1*& swapChain)
|
||||
IDXGIFactory2 *dxgiFactory = nullptr;
|
||||
result = dxgiAdapter->GetParent(__uuidof(IDXGIFactory2), reinterpret_cast<void**>(&dxgiFactory));
|
||||
|
||||
IDXGISwapChain1 *swapChain = nullptr;
|
||||
result = dxgiFactory->CreateSwapChainForHwnd(device, hWnd, &swapChainDesc, nullptr, nullptr, &swapChain);
|
||||
|
||||
// GP TODO: Fix the error handling here, it's bad...
|
||||
outSwapChain = swapChain;
|
||||
outDevice = device;
|
||||
outContext = context;
|
||||
}
|
||||
|
||||
bool GpDisplayDriverD3D11::InitResources()
|
||||
{
|
||||
// Fetch back buffer
|
||||
m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<LPVOID*>(m_backBufferTexture.GetMutablePtr()));
|
||||
|
||||
{
|
||||
D3D11_TEXTURE2D_DESC bbTextureDesc;
|
||||
m_backBufferTexture->GetDesc(&bbTextureDesc);
|
||||
|
||||
D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
|
||||
rtvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
|
||||
rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
rtvDesc.Texture2D.MipSlice = 0;
|
||||
|
||||
if (m_device->CreateRenderTargetView(m_backBufferTexture, &rtvDesc, m_backBufferRTV.GetMutablePtr()) != S_OK)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Quad vertex constant buffer
|
||||
{
|
||||
D3D11_BUFFER_DESC bufferDesc;
|
||||
bufferDesc.ByteWidth = sizeof(DrawQuadVertexConstants);
|
||||
bufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
bufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||
bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
bufferDesc.MiscFlags = 0;
|
||||
bufferDesc.StructureByteStride = 0;
|
||||
|
||||
if (m_device->CreateBuffer(&bufferDesc, nullptr, m_drawQuadVertexConstantBuffer.GetMutablePtr()) != S_OK)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Quad index buffer
|
||||
{
|
||||
const uint16_t indexBufferData[] = { 0, 1, 2, 1, 3, 2 };
|
||||
|
||||
D3D11_BUFFER_DESC bufferDesc;
|
||||
bufferDesc.ByteWidth = sizeof(indexBufferData);
|
||||
bufferDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||
bufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||
bufferDesc.CPUAccessFlags = 0;
|
||||
bufferDesc.MiscFlags = 0;
|
||||
bufferDesc.StructureByteStride = 0;
|
||||
|
||||
D3D11_SUBRESOURCE_DATA initialData;
|
||||
initialData.pSysMem = indexBufferData;
|
||||
initialData.SysMemPitch = 0;
|
||||
initialData.SysMemSlicePitch = 0;
|
||||
|
||||
if (m_device->CreateBuffer(&bufferDesc, &initialData, m_quadIndexBuffer.GetMutablePtr()) != S_OK)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Quad vertex buffer
|
||||
{
|
||||
const float vertexBufferData[] =
|
||||
{
|
||||
0.f, 0.0f,
|
||||
1.f, 0.f,
|
||||
0.f, 1.f,
|
||||
1.f, 1.f,
|
||||
};
|
||||
|
||||
D3D11_BUFFER_DESC bufferDesc;
|
||||
bufferDesc.ByteWidth = sizeof(vertexBufferData);
|
||||
bufferDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||
bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
bufferDesc.CPUAccessFlags = 0;
|
||||
bufferDesc.MiscFlags = 0;
|
||||
bufferDesc.StructureByteStride = 0;
|
||||
|
||||
D3D11_SUBRESOURCE_DATA initialData;
|
||||
initialData.pSysMem = vertexBufferData;
|
||||
initialData.SysMemPitch = 0;
|
||||
initialData.SysMemSlicePitch = 0;
|
||||
|
||||
if (m_device->CreateBuffer(&bufferDesc, &initialData, m_quadVertexBuffer.GetMutablePtr()) != S_OK)
|
||||
return false;
|
||||
}
|
||||
|
||||
const GpShaderCodeBlob drawQuadVBlob = GetBinarizedShader(GpBinarizedShaders::g_drawQuadV_D3D11);
|
||||
const GpShaderCodeBlob drawQuadPalettePBlob = GetBinarizedShader(GpBinarizedShaders::g_drawQuadPaletteP_D3D11);
|
||||
const GpShaderCodeBlob drawQuadRGBPBlob = GetBinarizedShader(GpBinarizedShaders::g_drawQuadRGBP_D3D11);
|
||||
const GpShaderCodeBlob drawQuad15BitPBlob = GetBinarizedShader(GpBinarizedShaders::g_drawQuad15BitP_D3D11);
|
||||
|
||||
m_device->CreateVertexShader(drawQuadVBlob.m_data, drawQuadVBlob.m_size, nullptr, m_drawQuadVertexShader.GetMutablePtr());
|
||||
m_device->CreatePixelShader(drawQuadPalettePBlob.m_data, drawQuadPalettePBlob.m_size, nullptr, m_drawQuadPalettePixelShader.GetMutablePtr());
|
||||
m_device->CreatePixelShader(drawQuadRGBPBlob.m_data, drawQuadRGBPBlob.m_size, nullptr, m_drawQuadRGBPixelShader.GetMutablePtr());
|
||||
m_device->CreatePixelShader(drawQuad15BitPBlob.m_data, drawQuad15BitPBlob.m_size, nullptr, m_drawQuad15BitPixelShader.GetMutablePtr());
|
||||
|
||||
// Quad input layout
|
||||
{
|
||||
D3D11_INPUT_ELEMENT_DESC descs[] =
|
||||
{
|
||||
"POSITION", // Semantic name
|
||||
0, // Semantic index
|
||||
DXGI_FORMAT_R32G32_FLOAT, // Format
|
||||
0, // Input slot
|
||||
0, // Aligned byte offset
|
||||
D3D11_INPUT_PER_VERTEX_DATA, // Input slot class
|
||||
0 // Instance data step rate
|
||||
};
|
||||
|
||||
m_device->CreateInputLayout(descs, sizeof(descs) / sizeof(descs[0]), drawQuadVBlob.m_data, drawQuadVBlob.m_size, m_drawQuadInputLayout.GetMutablePtr());
|
||||
}
|
||||
|
||||
// Quad depth stencil state
|
||||
{
|
||||
D3D11_DEPTH_STENCIL_DESC desc;
|
||||
desc.DepthEnable = FALSE;
|
||||
desc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
||||
desc.DepthFunc = D3D11_COMPARISON_ALWAYS;
|
||||
desc.StencilEnable = FALSE;
|
||||
desc.StencilReadMask = 0;
|
||||
desc.StencilWriteMask = 0;
|
||||
desc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
|
||||
desc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
||||
desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
||||
desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
||||
desc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
|
||||
desc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
||||
desc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
||||
desc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
||||
|
||||
if (m_device->CreateDepthStencilState(&desc, m_drawQuadDepthStencilState.GetMutablePtr()) != S_OK)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Nearest neighbor sampler desc
|
||||
{
|
||||
D3D11_SAMPLER_DESC samplerDesc;
|
||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.MipLODBias = 0.f;
|
||||
samplerDesc.MaxAnisotropy = 1;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
samplerDesc.BorderColor[0] = samplerDesc.BorderColor[1] = samplerDesc.BorderColor[2] = samplerDesc.BorderColor[3] = 1.0f;
|
||||
samplerDesc.MinLOD = -FLT_MAX;
|
||||
samplerDesc.MaxLOD = FLT_MAX;
|
||||
|
||||
if (m_device->CreateSamplerState(&samplerDesc, m_nearestNeighborSamplerState.GetMutablePtr()) != S_OK)
|
||||
return false;
|
||||
}
|
||||
|
||||
DXGI_FORMAT paletteTextureFormat = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
|
||||
|
||||
// Palette texture
|
||||
{
|
||||
D3D11_TEXTURE1D_DESC desc;
|
||||
desc.Width = 256;
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.Format = paletteTextureFormat;
|
||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
desc.MiscFlags = 0;
|
||||
|
||||
uint8_t initialDataBytes[256][4];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
for (int ch = 0; ch < 4; ch++)
|
||||
initialDataBytes[i][ch] = 255;
|
||||
}
|
||||
|
||||
D3D11_SUBRESOURCE_DATA initialData;
|
||||
initialData.pSysMem = initialDataBytes[0];
|
||||
initialData.SysMemPitch = 256 * 4;
|
||||
initialData.SysMemSlicePitch = 256 * 4;
|
||||
|
||||
if (m_device->CreateTexture1D(&desc, &initialData, m_paletteTexture.GetMutablePtr()) != S_OK)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Palette texture SRV
|
||||
{
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC desc;
|
||||
desc.Format = paletteTextureFormat;
|
||||
desc.ViewDimension = D3D_SRV_DIMENSION_TEXTURE1D;
|
||||
desc.Texture1D.MostDetailedMip = 0;
|
||||
desc.Texture1D.MipLevels = 1;
|
||||
|
||||
if (m_device->CreateShaderResourceView(m_paletteTexture, &desc, m_paletteTextureSRV.GetMutablePtr()) != S_OK)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool GpDisplayDriverD3D11::PresentFrameAndSync()
|
||||
{
|
||||
float clearColor[4] = { 0.5f, 0.5f, 0.5f, 1.0f };
|
||||
|
||||
m_deviceContext->ClearRenderTargetView(m_backBufferRTV, clearColor);
|
||||
|
||||
ID3D11RenderTargetView *const rtv = m_backBufferRTV;
|
||||
m_deviceContext->OMSetRenderTargets(1, &rtv, nullptr);
|
||||
|
||||
{
|
||||
D3D11_VIEWPORT viewport;
|
||||
viewport.TopLeftX = 0;
|
||||
viewport.TopLeftY = 0;
|
||||
viewport.Width = static_cast<FLOAT>(m_windowWidth);
|
||||
viewport.Height = static_cast<FLOAT>(m_windowHeight);
|
||||
viewport.MinDepth = 0.0f;
|
||||
viewport.MaxDepth = 1.0f;
|
||||
|
||||
m_deviceContext->RSSetViewports(1, &viewport);
|
||||
}
|
||||
|
||||
m_properties.m_renderFunc(m_properties.m_renderFuncContext);
|
||||
|
||||
DXGI_PRESENT_PARAMETERS presentParams;
|
||||
|
||||
ZeroMemory(&presentParams, sizeof(presentParams));
|
||||
@@ -228,11 +473,13 @@ void GpDisplayDriverD3D11::Run()
|
||||
RECT wr = { 0, 0, m_windowWidth, m_windowHeight };
|
||||
AdjustWindowRect(&wr, windowStyle, menus != NULL);
|
||||
|
||||
hWnd = CreateWindowExW(NULL, L"GPD3D11WindowClass", L"GlidePort", WS_OVERLAPPEDWINDOW, 300, 300, wr.right - wr.left, wr.bottom - wr.top, NULL, menus, g_gpWindowsGlobals.m_hInstance, NULL);
|
||||
hWnd = CreateWindowExW(NULL, L"GPD3D11WindowClass", L"GlidePort (Direct3D 11)", WS_OVERLAPPEDWINDOW, 300, 300, wr.right - wr.left, wr.bottom - wr.top, NULL, menus, g_gpWindowsGlobals.m_hInstance, NULL);
|
||||
|
||||
ShowWindow(hWnd, g_gpWindowsGlobals.m_nCmdShow);
|
||||
|
||||
StartD3DForWindow(hWnd, m_swapChain);
|
||||
StartD3DForWindow(hWnd, m_swapChain, m_device, m_deviceContext);
|
||||
|
||||
InitResources();
|
||||
|
||||
LARGE_INTEGER lastTimestamp;
|
||||
memset(&lastTimestamp, 0, sizeof(lastTimestamp));
|
||||
@@ -274,6 +521,117 @@ void GpDisplayDriverD3D11::GetDisplayResolution(unsigned int *width, unsigned in
|
||||
*pixelFormat = PortabilityLayer::PixelFormat_8BitStandard;
|
||||
}
|
||||
|
||||
IGpDisplayDriverSurface *GpDisplayDriverD3D11::CreateSurface(size_t width, size_t height, PortabilityLayer::PixelFormat pixelFormat)
|
||||
{
|
||||
return GpDisplayDriverSurfaceD3D11::Create(m_device, m_deviceContext, width, height, pixelFormat);
|
||||
}
|
||||
|
||||
void GpDisplayDriverD3D11::DrawSurface(IGpDisplayDriverSurface *surface, size_t x, size_t y, size_t width, size_t height)
|
||||
{
|
||||
ID3D11Buffer *vbPtr = m_quadVertexBuffer;
|
||||
UINT vbStride = sizeof(float) * 2;
|
||||
UINT zero = 0;
|
||||
|
||||
GpDisplayDriverSurfaceD3D11 *d3d11Surface = static_cast<GpDisplayDriverSurfaceD3D11*>(surface);
|
||||
|
||||
//m_deviceContext->OMSetDepthStencilState(m_drawQuadDepthStencilState, 0);
|
||||
|
||||
{
|
||||
const float twoDivWidth = 2.0f / static_cast<float>(m_windowWidth);
|
||||
const float negativeTwoDivHeight = -2.0f / static_cast<float>(m_windowHeight);
|
||||
|
||||
DrawQuadVertexConstants constantsData;
|
||||
constantsData.m_ndcOriginX = static_cast<float>(x) * twoDivWidth - 1.0f;
|
||||
constantsData.m_ndcOriginY = static_cast<float>(y) * negativeTwoDivHeight + 1.0f;
|
||||
constantsData.m_ndcWidth = static_cast<float>(width) * twoDivWidth;
|
||||
constantsData.m_ndcHeight = static_cast<float>(height) * negativeTwoDivHeight;
|
||||
|
||||
constantsData.m_surfaceDimensionX = static_cast<float>(d3d11Surface->GetWidth());
|
||||
constantsData.m_surfaceDimensionY = static_cast<float>(d3d11Surface->GetHeight());
|
||||
|
||||
D3D11_MAPPED_SUBRESOURCE mappedConstants;
|
||||
if (m_deviceContext->Map(m_drawQuadVertexConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedConstants) == S_OK)
|
||||
{
|
||||
memcpy(mappedConstants.pData, &constantsData, sizeof(constantsData));
|
||||
m_deviceContext->Unmap(m_drawQuadVertexConstantBuffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
m_deviceContext->IASetVertexBuffers(0, 1, &vbPtr, &vbStride, &zero);
|
||||
m_deviceContext->IASetIndexBuffer(m_quadIndexBuffer, DXGI_FORMAT_R16_UINT, 0);
|
||||
m_deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
m_deviceContext->IASetInputLayout(m_drawQuadInputLayout);
|
||||
|
||||
ID3D11Buffer *vsConstants = m_drawQuadVertexConstantBuffer;
|
||||
m_deviceContext->VSSetShader(m_drawQuadVertexShader, nullptr, 0);
|
||||
m_deviceContext->VSSetConstantBuffers(0, 1, &vsConstants);
|
||||
|
||||
ID3D11SamplerState *samplerStates[] =
|
||||
{
|
||||
m_nearestNeighborSamplerState,
|
||||
};
|
||||
m_deviceContext->PSSetSamplers(0, sizeof(samplerStates) / sizeof(samplerStates[0]), samplerStates);
|
||||
|
||||
PortabilityLayer::PixelFormat pixelFormat = d3d11Surface->GetPixelFormat();
|
||||
if (pixelFormat == PortabilityLayer::PixelFormat_8BitStandard || pixelFormat == PortabilityLayer::PixelFormat_8BitCustom)
|
||||
{
|
||||
ID3D11ShaderResourceView *psResourceViews[] =
|
||||
{
|
||||
d3d11Surface->GetSRV(),
|
||||
m_paletteTextureSRV
|
||||
};
|
||||
|
||||
m_deviceContext->PSSetShader(m_drawQuadPalettePixelShader, nullptr, 0);
|
||||
m_deviceContext->PSSetShaderResources(0, sizeof(psResourceViews) / sizeof(psResourceViews[0]), psResourceViews);
|
||||
}
|
||||
else if (pixelFormat == PortabilityLayer::PixelFormat_RGB555)
|
||||
{
|
||||
ID3D11ShaderResourceView *psResourceViews[] =
|
||||
{
|
||||
d3d11Surface->GetSRV(),
|
||||
};
|
||||
|
||||
m_deviceContext->PSSetShader(m_drawQuad15BitPixelShader, nullptr, 0);
|
||||
m_deviceContext->PSSetShaderResources(0, sizeof(psResourceViews) / sizeof(psResourceViews[0]), psResourceViews);
|
||||
}
|
||||
else if (pixelFormat == PortabilityLayer::PixelFormat_RGB32)
|
||||
{
|
||||
ID3D11ShaderResourceView *psResourceViews[] =
|
||||
{
|
||||
d3d11Surface->GetSRV(),
|
||||
};
|
||||
|
||||
m_deviceContext->PSSetShader(m_drawQuadRGBPixelShader, nullptr, 0);
|
||||
m_deviceContext->PSSetShaderResources(0, sizeof(psResourceViews) / sizeof(psResourceViews[0]), psResourceViews);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_deviceContext->DrawIndexed(6, 0, 0);
|
||||
}
|
||||
|
||||
void GpDisplayDriverD3D11::UpdatePalette(const void *paletteData)
|
||||
{
|
||||
const size_t dataSize = 256 * 4;
|
||||
const uint8_t *paletteDataBytes = static_cast<const uint8_t *>(paletteData);
|
||||
|
||||
D3D11_MAPPED_SUBRESOURCE mappedResource;
|
||||
if (m_deviceContext->Map(m_paletteTexture, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource) == S_OK)
|
||||
{
|
||||
uint8_t *textureDataBytes = static_cast<uint8_t *>(mappedResource.pData);
|
||||
|
||||
for (size_t chunkOffset = 0; chunkOffset < dataSize; chunkOffset += sizeof(__m128i))
|
||||
{
|
||||
__m128i chunkData = _mm_loadu_si128(reinterpret_cast<const __m128i*>(paletteDataBytes + chunkOffset));
|
||||
_mm_stream_si128(reinterpret_cast<__m128i*>(textureDataBytes + chunkOffset), chunkData);
|
||||
}
|
||||
|
||||
m_deviceContext->Unmap(m_paletteTexture, 0);
|
||||
}
|
||||
}
|
||||
|
||||
GpDisplayDriverD3D11 *GpDisplayDriverD3D11::Create(const GpDisplayDriverProperties &properties)
|
||||
{
|
||||
return new GpDisplayDriverD3D11(properties);
|
||||
@@ -292,3 +650,7 @@ GpDisplayDriverD3D11::GpDisplayDriverD3D11(const GpDisplayDriverProperties &prop
|
||||
|
||||
m_frameTimeSliceSize = m_QPFrequency.QuadPart * static_cast<LONGLONG>(properties.m_frameTimeLockNumerator) / static_cast<LONGLONG>(properties.m_frameTimeLockDenominator);
|
||||
}
|
||||
|
||||
GpDisplayDriverD3D11::~GpDisplayDriverD3D11()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -6,10 +6,23 @@
|
||||
#include "IGpDisplayDriver.h"
|
||||
#include "GpCoreDefs.h"
|
||||
#include "GpDisplayDriverProperties.h"
|
||||
#include "GpComPtr.h"
|
||||
|
||||
#include "PixelFormat.h"
|
||||
|
||||
struct IDXGISwapChain1;
|
||||
struct ID3D11Buffer;
|
||||
struct ID3D11DepthStencilState;
|
||||
struct ID3D11Device;
|
||||
struct ID3D11DeviceContext;
|
||||
struct ID3D11InputLayout;
|
||||
struct ID3D11PixelShader;
|
||||
struct ID3D11RenderTargetView;
|
||||
struct ID3D11SamplerState;
|
||||
struct ID3D11ShaderResourceView;
|
||||
struct ID3D11Texture1D;
|
||||
struct ID3D11Texture2D;
|
||||
struct ID3D11VertexShader;
|
||||
|
||||
class GpDisplayDriverD3D11 : public IGpDisplayDriver
|
||||
{
|
||||
@@ -19,14 +32,50 @@ public:
|
||||
|
||||
void GetDisplayResolution(unsigned int *width, unsigned int *height, PortabilityLayer::PixelFormat *bpp) override;
|
||||
|
||||
IGpDisplayDriverSurface *CreateSurface(size_t width, size_t height, PortabilityLayer::PixelFormat pixelFormat) override;
|
||||
void DrawSurface(IGpDisplayDriverSurface *surface, size_t x, size_t y, size_t width, size_t height) override;
|
||||
|
||||
void UpdatePalette(const void *paletteData) override;
|
||||
|
||||
static GpDisplayDriverD3D11 *Create(const GpDisplayDriverProperties &properties);
|
||||
|
||||
private:
|
||||
GpDisplayDriverD3D11(const GpDisplayDriverProperties &properties);
|
||||
struct DrawQuadVertexConstants
|
||||
{
|
||||
float m_ndcOriginX;
|
||||
float m_ndcOriginY;
|
||||
float m_ndcWidth;
|
||||
float m_ndcHeight;
|
||||
|
||||
float m_surfaceDimensionX;
|
||||
float m_surfaceDimensionY;
|
||||
float m_unused[2];
|
||||
};
|
||||
|
||||
GpDisplayDriverD3D11(const GpDisplayDriverProperties &properties);
|
||||
~GpDisplayDriverD3D11();
|
||||
|
||||
bool InitResources();
|
||||
bool PresentFrameAndSync();
|
||||
|
||||
IDXGISwapChain1 *m_swapChain;
|
||||
GpComPtr<IDXGISwapChain1> m_swapChain;
|
||||
GpComPtr<ID3D11Device> m_device;
|
||||
GpComPtr<ID3D11DeviceContext> m_deviceContext;
|
||||
GpComPtr<ID3D11Buffer> m_quadIndexBuffer;
|
||||
GpComPtr<ID3D11Buffer> m_quadVertexBuffer;
|
||||
GpComPtr<ID3D11InputLayout> m_drawQuadInputLayout;
|
||||
GpComPtr<ID3D11VertexShader> m_drawQuadVertexShader;
|
||||
GpComPtr<ID3D11PixelShader> m_drawQuadPalettePixelShader;
|
||||
GpComPtr<ID3D11PixelShader> m_drawQuad15BitPixelShader;
|
||||
GpComPtr<ID3D11PixelShader> m_drawQuadRGBPixelShader;
|
||||
GpComPtr<ID3D11Buffer> m_drawQuadVertexConstantBuffer;
|
||||
GpComPtr<ID3D11DepthStencilState> m_drawQuadDepthStencilState;
|
||||
GpComPtr<ID3D11SamplerState> m_nearestNeighborSamplerState;
|
||||
GpComPtr<ID3D11Texture1D> m_paletteTexture;
|
||||
GpComPtr<ID3D11ShaderResourceView> m_paletteTextureSRV;
|
||||
|
||||
GpComPtr<ID3D11Texture2D> m_backBufferTexture;
|
||||
GpComPtr<ID3D11RenderTargetView> m_backBufferRTV;
|
||||
|
||||
struct CompactedPresentHistoryItem
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "EGpDisplayDriverType.h"
|
||||
|
||||
class IGpDisplayDriver;
|
||||
struct IGpDisplayDriver;
|
||||
struct GpDisplayDriverProperties;
|
||||
|
||||
class GpDisplayDriverFactory
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
class IGpDisplayDriver;
|
||||
struct IGpDisplayDriver;
|
||||
struct GpDisplayDriverProperties;
|
||||
|
||||
class GpDisplayDriverFactoryD3D11
|
||||
|
||||
153
GpD3D/GpDisplayDriverSurfaceD3D11.cpp
Normal file
153
GpD3D/GpDisplayDriverSurfaceD3D11.cpp
Normal file
@@ -0,0 +1,153 @@
|
||||
#include "GpDisplayDriverSurfaceD3D11.h"
|
||||
#include "GpComPtr.h"
|
||||
|
||||
#include <d3d11.h>
|
||||
#include <emmintrin.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <new>
|
||||
|
||||
void GpDisplayDriverSurfaceD3D11::Upload(const void *data, size_t x, size_t y, size_t width, size_t height, size_t pitch)
|
||||
{
|
||||
D3D11_BOX box;
|
||||
box.left = x;
|
||||
box.right = x + width;
|
||||
box.top = y;
|
||||
box.bottom = y + height;
|
||||
box.front = 0;
|
||||
box.back = 1;
|
||||
|
||||
m_deviceContext->UpdateSubresource(m_texture, 0, &box, data, pitch, height * pitch);
|
||||
}
|
||||
|
||||
void GpDisplayDriverSurfaceD3D11::UploadEntire(const void *data, size_t pitch)
|
||||
{
|
||||
D3D11_MAPPED_SUBRESOURCE mappedRes;
|
||||
if (m_deviceContext->Map(m_texture, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedRes) == S_OK)
|
||||
{
|
||||
if (mappedRes.RowPitch < pitch || (pitch % 16) != 0)
|
||||
return; // This should not happen, D3D10+ feature level should guarantee 16-byte alignment
|
||||
|
||||
const size_t destPitch = mappedRes.RowPitch;
|
||||
|
||||
const uint8_t *srcBytes = static_cast<const uint8_t*>(data);
|
||||
uint8_t *destBytes = static_cast<uint8_t*>(mappedRes.pData);
|
||||
|
||||
const size_t height = m_height;
|
||||
const size_t numM128PerRow = pitch / 16;
|
||||
|
||||
for (size_t row = 0; row < height; row++)
|
||||
{
|
||||
for (size_t moffs = 0; moffs < numM128PerRow; moffs++)
|
||||
{
|
||||
const __m128i v = _mm_load_si128(reinterpret_cast<const __m128i*>(srcBytes + moffs * 16));
|
||||
_mm_stream_si128(reinterpret_cast<__m128i*>(destBytes + moffs * 16), v);
|
||||
}
|
||||
|
||||
srcBytes += pitch;
|
||||
destBytes += destPitch;
|
||||
}
|
||||
|
||||
m_deviceContext->Unmap(m_texture, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void GpDisplayDriverSurfaceD3D11::Destroy()
|
||||
{
|
||||
this->~GpDisplayDriverSurfaceD3D11();
|
||||
free(this);
|
||||
}
|
||||
|
||||
ID3D11ShaderResourceView *GpDisplayDriverSurfaceD3D11::GetSRV() const
|
||||
{
|
||||
return m_srv;
|
||||
}
|
||||
|
||||
PortabilityLayer::PixelFormat GpDisplayDriverSurfaceD3D11::GetPixelFormat() const
|
||||
{
|
||||
return m_pixelFormat;
|
||||
}
|
||||
|
||||
size_t GpDisplayDriverSurfaceD3D11::GetWidth() const
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
|
||||
size_t GpDisplayDriverSurfaceD3D11::GetHeight() const
|
||||
{
|
||||
return m_height;
|
||||
}
|
||||
|
||||
GpDisplayDriverSurfaceD3D11 *GpDisplayDriverSurfaceD3D11::Create(ID3D11Device *device, ID3D11DeviceContext *deviceContext, size_t width, size_t height, PortabilityLayer::PixelFormat pixelFormat)
|
||||
{
|
||||
DXGI_FORMAT dxgiFormat = DXGI_FORMAT_R8_UNORM;
|
||||
|
||||
switch (pixelFormat)
|
||||
{
|
||||
case PortabilityLayer::PixelFormat_8BitCustom:
|
||||
case PortabilityLayer::PixelFormat_8BitStandard:
|
||||
dxgiFormat = DXGI_FORMAT_R8_UINT;
|
||||
break;
|
||||
case PortabilityLayer::PixelFormat_RGB555:
|
||||
dxgiFormat = DXGI_FORMAT_R16_UINT;
|
||||
break;
|
||||
case PortabilityLayer::PixelFormat_RGB32:
|
||||
dxgiFormat = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
|
||||
break;
|
||||
case PortabilityLayer::PixelFormat_RGB24: // RGB24 is not supported as a surface format (PL must convert it)
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
D3D11_TEXTURE2D_DESC textureDesc;
|
||||
textureDesc.Width = static_cast<UINT>(width);
|
||||
textureDesc.Height = static_cast<UINT>(height);
|
||||
textureDesc.MipLevels = 1;
|
||||
textureDesc.ArraySize = 1;
|
||||
textureDesc.Format = dxgiFormat;
|
||||
textureDesc.SampleDesc.Count = 1;
|
||||
textureDesc.SampleDesc.Quality = 0;
|
||||
textureDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
textureDesc.MiscFlags = 0;
|
||||
|
||||
GpComPtr<ID3D11Texture2D> texture;
|
||||
if (device->CreateTexture2D(&textureDesc, nullptr, texture.GetMutablePtr()) != S_OK)
|
||||
return nullptr;
|
||||
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
|
||||
srvDesc.Format = dxgiFormat;
|
||||
srvDesc.ViewDimension = D3D_SRV_DIMENSION_TEXTURE2D;
|
||||
srvDesc.Texture2D.MipLevels = 1;
|
||||
srvDesc.Texture2D.MostDetailedMip = 0;
|
||||
|
||||
GpComPtr<ID3D11ShaderResourceView> srv;
|
||||
if (device->CreateShaderResourceView(texture, &srvDesc, srv.GetMutablePtr()) != S_OK)
|
||||
return nullptr;
|
||||
|
||||
void *storage = malloc(sizeof(GpDisplayDriverSurfaceD3D11));
|
||||
if (!storage)
|
||||
{
|
||||
texture->Release();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new (storage) GpDisplayDriverSurfaceD3D11(device, deviceContext, texture, srv, width, height, pixelFormat);
|
||||
}
|
||||
|
||||
GpDisplayDriverSurfaceD3D11::GpDisplayDriverSurfaceD3D11(ID3D11Device *device, ID3D11DeviceContext *deviceContext, ID3D11Texture2D *texture, ID3D11ShaderResourceView *srv, size_t width, size_t height, PortabilityLayer::PixelFormat pixelFormat)
|
||||
: m_width(width)
|
||||
, m_height(height)
|
||||
, m_pixelFormat(pixelFormat)
|
||||
, m_device(device)
|
||||
, m_deviceContext(deviceContext)
|
||||
, m_texture(texture)
|
||||
, m_srv(srv)
|
||||
{
|
||||
}
|
||||
|
||||
GpDisplayDriverSurfaceD3D11::~GpDisplayDriverSurfaceD3D11()
|
||||
{
|
||||
}
|
||||
38
GpD3D/GpDisplayDriverSurfaceD3D11.h
Normal file
38
GpD3D/GpDisplayDriverSurfaceD3D11.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include "IGpDisplayDriverSurface.h"
|
||||
#include "GpComPtr.h"
|
||||
#include "PixelFormat.h"
|
||||
|
||||
struct ID3D11Device;
|
||||
struct ID3D11DeviceContext;
|
||||
struct ID3D11ShaderResourceView;
|
||||
struct ID3D11Texture2D;
|
||||
|
||||
class GpDisplayDriverSurfaceD3D11 final : public IGpDisplayDriverSurface
|
||||
{
|
||||
public:
|
||||
virtual void Upload(const void *data, size_t x, size_t y, size_t width, size_t height, size_t pitch) override;
|
||||
virtual void UploadEntire(const void *data, size_t pitch) override;
|
||||
virtual void Destroy() override;
|
||||
|
||||
ID3D11ShaderResourceView *GetSRV() const;
|
||||
PortabilityLayer::PixelFormat GetPixelFormat() const;
|
||||
size_t GetWidth() const;
|
||||
size_t GetHeight() const;
|
||||
|
||||
static GpDisplayDriverSurfaceD3D11 *Create(ID3D11Device *device, ID3D11DeviceContext *deviceContext, size_t width, size_t height, PortabilityLayer::PixelFormat pixelFormat);
|
||||
|
||||
private:
|
||||
GpDisplayDriverSurfaceD3D11(ID3D11Device *device, ID3D11DeviceContext *deviceContext, ID3D11Texture2D *texture, ID3D11ShaderResourceView *srv, size_t width, size_t height, PortabilityLayer::PixelFormat pixelFormat);
|
||||
~GpDisplayDriverSurfaceD3D11();
|
||||
|
||||
size_t m_width;
|
||||
size_t m_height;
|
||||
PortabilityLayer::PixelFormat m_pixelFormat;
|
||||
ID3D11Device *m_device;
|
||||
ID3D11DeviceContext *m_deviceContext;
|
||||
|
||||
GpComPtr<ID3D11Texture2D> m_texture;
|
||||
GpComPtr<ID3D11ShaderResourceView> m_srv;
|
||||
};
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "GpFileSystem_Win32.h"
|
||||
#include "GpFileStream_Win32.h"
|
||||
#include "GpWindows.h"
|
||||
#include "GpFileSystem_Win32.h"
|
||||
#include "GpFileStream_Win32.h"
|
||||
#include "GpWindows.h"
|
||||
#include "GpMemoryBuffer.h"
|
||||
#include "HostDirectoryCursor.h"
|
||||
|
||||
#include <string>
|
||||
#include <Shlwapi.h>
|
||||
#include "HostDirectoryCursor.h"
|
||||
|
||||
#include <string>
|
||||
#include <Shlwapi.h>
|
||||
#include <ShlObj.h>
|
||||
#include <assert.h>
|
||||
|
||||
@@ -24,7 +24,7 @@ private:
|
||||
HANDLE m_handle;
|
||||
WIN32_FIND_DATAW m_findData;
|
||||
char m_chars[MAX_PATH + 1];
|
||||
bool m_haveNext;
|
||||
bool m_haveNext;
|
||||
};
|
||||
|
||||
GpDirectoryCursor_Win32 *GpDirectoryCursor_Win32::Create(const HANDLE &handle, const WIN32_FIND_DATAW &findData)
|
||||
@@ -85,66 +85,111 @@ GpDirectoryCursor_Win32::GpDirectoryCursor_Win32(const HANDLE &handle, const WIN
|
||||
: m_handle(handle)
|
||||
, m_findData(findData)
|
||||
, m_haveNext(true)
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
GpDirectoryCursor_Win32::~GpDirectoryCursor_Win32()
|
||||
{
|
||||
FindClose(m_handle);
|
||||
}
|
||||
|
||||
GpFileSystem_Win32::GpFileSystem_Win32()
|
||||
{
|
||||
PWSTR docsPath;
|
||||
if (!FAILED(SHGetKnownFolderPath(FOLDERID_Documents, KF_FLAG_DEFAULT, nullptr, &docsPath)))
|
||||
{
|
||||
try
|
||||
{
|
||||
m_prefsDir = docsPath;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
CoTaskMemFree(docsPath);
|
||||
throw;
|
||||
}
|
||||
|
||||
m_prefsDir.append(L"\\GlidePort");
|
||||
|
||||
CreateDirectoryW(m_prefsDir.c_str(), nullptr);
|
||||
m_prefsDir.append(L"\\");
|
||||
}
|
||||
}
|
||||
|
||||
bool GpFileSystem_Win32::FileExists(PortabilityLayer::EVirtualDirectory virtualDirectory, const char *path)
|
||||
{
|
||||
wchar_t winPath[MAX_PATH + 1];
|
||||
|
||||
if (!ResolvePath(virtualDirectory, path, winPath))
|
||||
return false;
|
||||
|
||||
return PathFileExistsW(winPath) != 0;
|
||||
}
|
||||
|
||||
PortabilityLayer::IOStream *GpFileSystem_Win32::OpenFile(PortabilityLayer::EVirtualDirectory virtualDirectory, const char *path, bool writeAccess, bool create)
|
||||
{
|
||||
wchar_t winPath[MAX_PATH + 1];
|
||||
|
||||
if (!ResolvePath(virtualDirectory, path, winPath))
|
||||
return false;
|
||||
|
||||
const DWORD desiredAccess = writeAccess ? (GENERIC_WRITE | GENERIC_READ) : GENERIC_READ;
|
||||
const DWORD creationDisposition = create ? OPEN_ALWAYS : OPEN_EXISTING;
|
||||
|
||||
HANDLE h = CreateFileW(winPath, desiredAccess, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
|
||||
return new GpFileStream_Win32(h, true, writeAccess, true);
|
||||
|
||||
GpFileSystem_Win32::GpFileSystem_Win32()
|
||||
{
|
||||
m_executablePath[0] = 0;
|
||||
|
||||
PWSTR docsPath;
|
||||
if (!FAILED(SHGetKnownFolderPath(FOLDERID_Documents, KF_FLAG_DEFAULT, nullptr, &docsPath)))
|
||||
{
|
||||
try
|
||||
{
|
||||
m_prefsDir = docsPath;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
CoTaskMemFree(docsPath);
|
||||
throw;
|
||||
}
|
||||
|
||||
m_prefsDir.append(L"\\GlidePort");
|
||||
|
||||
CreateDirectoryW(m_prefsDir.c_str(), nullptr);
|
||||
m_prefsDir.append(L"\\");
|
||||
}
|
||||
|
||||
DWORD modulePathSize = GetModuleFileNameW(nullptr, m_executablePath, MAX_PATH);
|
||||
if (modulePathSize == MAX_PATH || modulePathSize == 0)
|
||||
m_executablePath[0] = 0;
|
||||
|
||||
size_t currentPathLength = wcslen(m_executablePath);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
while (currentPathLength > 0 && m_executablePath[currentPathLength - 1] != '\\')
|
||||
currentPathLength--;
|
||||
|
||||
m_executablePath[currentPathLength] = 0;
|
||||
|
||||
if (currentPathLength + 11 > MAX_PATH)
|
||||
{
|
||||
// "Resources" append is a longer path than the executable
|
||||
continue;
|
||||
}
|
||||
|
||||
if (wcscat_s(m_executablePath, L"Resources"))
|
||||
{
|
||||
currentPathLength = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (PathFileExistsW(m_executablePath) && PathIsDirectoryW(m_executablePath))
|
||||
{
|
||||
m_executablePath[currentPathLength] = 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
currentPathLength--;
|
||||
}
|
||||
|
||||
if (currentPathLength > 0)
|
||||
{
|
||||
m_packagedDir = std::wstring(m_executablePath) + L"Packaged\\";
|
||||
m_housesDir = std::wstring(m_executablePath) + L"Packaged\\Houses\\";
|
||||
m_resourcesDir = std::wstring(m_executablePath) + L"Resources\\";
|
||||
}
|
||||
}
|
||||
|
||||
bool GpFileSystem_Win32::FileExists(PortabilityLayer::EVirtualDirectory virtualDirectory, const char *path)
|
||||
{
|
||||
wchar_t winPath[MAX_PATH + 1];
|
||||
|
||||
if (!ResolvePath(virtualDirectory, path, winPath))
|
||||
return false;
|
||||
|
||||
return PathFileExistsW(winPath) != 0;
|
||||
}
|
||||
|
||||
PortabilityLayer::IOStream *GpFileSystem_Win32::OpenFile(PortabilityLayer::EVirtualDirectory virtualDirectory, const char *path, bool writeAccess, bool create)
|
||||
{
|
||||
wchar_t winPath[MAX_PATH + 1];
|
||||
|
||||
if (!ResolvePath(virtualDirectory, path, winPath))
|
||||
return false;
|
||||
|
||||
const DWORD desiredAccess = writeAccess ? (GENERIC_WRITE | GENERIC_READ) : GENERIC_READ;
|
||||
const DWORD creationDisposition = create ? OPEN_ALWAYS : OPEN_EXISTING;
|
||||
|
||||
HANDLE h = CreateFileW(winPath, desiredAccess, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
|
||||
return new GpFileStream_Win32(h, true, writeAccess, true);
|
||||
}
|
||||
|
||||
PortabilityLayer::HostDirectoryCursor *GpFileSystem_Win32::ScanDirectory(PortabilityLayer::EVirtualDirectory virtualDirectory)
|
||||
{
|
||||
wchar_t winPath[MAX_PATH + 2];
|
||||
|
||||
if (!ResolvePath(virtualDirectory, "*", winPath))
|
||||
{
|
||||
wchar_t winPath[MAX_PATH + 2];
|
||||
|
||||
if (!ResolvePath(virtualDirectory, "*", winPath))
|
||||
return nullptr;
|
||||
|
||||
WIN32_FIND_DATAW findData;
|
||||
@@ -153,49 +198,52 @@ PortabilityLayer::HostDirectoryCursor *GpFileSystem_Win32::ScanDirectory(Portabi
|
||||
if (ff == INVALID_HANDLE_VALUE)
|
||||
return nullptr;
|
||||
|
||||
return GpDirectoryCursor_Win32::Create(ff, findData);
|
||||
}
|
||||
|
||||
GpFileSystem_Win32 *GpFileSystem_Win32::GetInstance()
|
||||
{
|
||||
return &ms_instance;
|
||||
}
|
||||
|
||||
bool GpFileSystem_Win32::ResolvePath(PortabilityLayer::EVirtualDirectory virtualDirectory, const char *path, wchar_t *outPath)
|
||||
{
|
||||
const wchar_t *baseDir = nullptr;
|
||||
|
||||
switch (virtualDirectory)
|
||||
{
|
||||
case PortabilityLayer::EVirtualDirectory_ApplicationData:
|
||||
baseDir = L"D:\\Source Code\\GlidePort\\Packaged\\";
|
||||
break;
|
||||
case PortabilityLayer::EVirtualDirectory_GameData:
|
||||
baseDir = L"D:\\Source Code\\GlidePort\\Packaged\\Houses\\";
|
||||
break;
|
||||
case PortabilityLayer::EVirtualDirectory_Prefs:
|
||||
baseDir = m_prefsDir.c_str();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (baseDir == nullptr)
|
||||
return false;
|
||||
|
||||
const size_t baseDirLen = wcslen(baseDir);
|
||||
const size_t pathLen = strlen(path);
|
||||
|
||||
if (baseDirLen >= MAX_PATH || MAX_PATH - baseDirLen < pathLen)
|
||||
return false;
|
||||
|
||||
memcpy(outPath, baseDir, sizeof(wchar_t) * baseDirLen);
|
||||
for (size_t i = 0; i < pathLen; i++)
|
||||
outPath[baseDirLen + i] = static_cast<wchar_t>(path[i]);
|
||||
|
||||
outPath[baseDirLen + pathLen] = static_cast<wchar_t>(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GpFileSystem_Win32 GpFileSystem_Win32::ms_instance;
|
||||
return GpDirectoryCursor_Win32::Create(ff, findData);
|
||||
}
|
||||
|
||||
GpFileSystem_Win32 *GpFileSystem_Win32::GetInstance()
|
||||
{
|
||||
return &ms_instance;
|
||||
}
|
||||
|
||||
bool GpFileSystem_Win32::ResolvePath(PortabilityLayer::EVirtualDirectory virtualDirectory, const char *path, wchar_t *outPath)
|
||||
{
|
||||
const wchar_t *baseDir = nullptr;
|
||||
|
||||
switch (virtualDirectory)
|
||||
{
|
||||
case PortabilityLayer::EVirtualDirectory_ApplicationData:
|
||||
baseDir = m_packagedDir.c_str();
|
||||
break;
|
||||
case PortabilityLayer::EVirtualDirectory_GameData:
|
||||
baseDir = m_housesDir.c_str();
|
||||
break;
|
||||
case PortabilityLayer::EVirtualDirectory_Prefs:
|
||||
baseDir = m_prefsDir.c_str();
|
||||
break;
|
||||
case PortabilityLayer::EVirtualDirectory_Fonts:
|
||||
baseDir = m_resourcesDir.c_str();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (baseDir == nullptr)
|
||||
return false;
|
||||
|
||||
const size_t baseDirLen = wcslen(baseDir);
|
||||
const size_t pathLen = strlen(path);
|
||||
|
||||
if (baseDirLen >= MAX_PATH || MAX_PATH - baseDirLen < pathLen)
|
||||
return false;
|
||||
|
||||
memcpy(outPath, baseDir, sizeof(wchar_t) * baseDirLen);
|
||||
for (size_t i = 0; i < pathLen; i++)
|
||||
outPath[baseDirLen + i] = static_cast<wchar_t>(path[i]);
|
||||
|
||||
outPath[baseDirLen + pathLen] = static_cast<wchar_t>(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GpFileSystem_Win32 GpFileSystem_Win32::ms_instance;
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
#include "HostFileSystem.h"
|
||||
|
||||
#include "GpCoreDefs.h"
|
||||
#include "GpCoreDefs.h"
|
||||
#include "GpWindows.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -21,6 +22,10 @@ private:
|
||||
bool ResolvePath(PortabilityLayer::EVirtualDirectory virtualDirectory, const char *path, wchar_t *outPath);
|
||||
|
||||
std::wstring m_prefsDir;
|
||||
std::wstring m_packagedDir;
|
||||
std::wstring m_housesDir;
|
||||
std::wstring m_resourcesDir;
|
||||
wchar_t m_executablePath[MAX_PATH];
|
||||
|
||||
static GpFileSystem_Win32 ms_instance;
|
||||
};
|
||||
|
||||
9
GpD3D/GpFontHandlerFactory.cpp
Normal file
9
GpD3D/GpFontHandlerFactory.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "GpFontHandlerFactory.h"
|
||||
#include "GpFontHandler_FreeType2.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
PortabilityLayer::HostFontHandler *GpFontHandlerFactory::Create()
|
||||
{
|
||||
return GpFontHandler_FreeType2::Create();
|
||||
}
|
||||
12
GpD3D/GpFontHandlerFactory.h
Normal file
12
GpD3D/GpFontHandlerFactory.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class HostFontHandler;
|
||||
}
|
||||
|
||||
class GpFontHandlerFactory final
|
||||
{
|
||||
public:
|
||||
static PortabilityLayer::HostFontHandler *Create();
|
||||
};
|
||||
189
GpD3D/GpFontHandler_FreeType2.cpp
Normal file
189
GpD3D/GpFontHandler_FreeType2.cpp
Normal file
@@ -0,0 +1,189 @@
|
||||
#include "GpFontHandler_FreeType2.h"
|
||||
|
||||
#include "IOStream.h"
|
||||
#include "HostFont.h"
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_MODULE_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <new>
|
||||
#include <assert.h>
|
||||
|
||||
class GpFont_FreeType2 final : public PortabilityLayer::HostFont
|
||||
{
|
||||
public:
|
||||
void Destroy() override;
|
||||
|
||||
static GpFont_FreeType2 *Create(FT_Face face);
|
||||
|
||||
private:
|
||||
explicit GpFont_FreeType2(FT_Face face);
|
||||
~GpFont_FreeType2();
|
||||
|
||||
FT_Face m_face;
|
||||
};
|
||||
|
||||
|
||||
void GpFont_FreeType2::Destroy()
|
||||
{
|
||||
this->~GpFont_FreeType2();
|
||||
free(this);
|
||||
}
|
||||
|
||||
GpFont_FreeType2 *GpFont_FreeType2::Create(FT_Face face)
|
||||
{
|
||||
void *storage = malloc(sizeof(GpFont_FreeType2));
|
||||
if (!storage)
|
||||
return nullptr;
|
||||
|
||||
return new (storage) GpFont_FreeType2(face);
|
||||
}
|
||||
|
||||
GpFont_FreeType2::GpFont_FreeType2(FT_Face face)
|
||||
: m_face(face)
|
||||
{
|
||||
}
|
||||
|
||||
GpFont_FreeType2::~GpFont_FreeType2()
|
||||
{
|
||||
FT_Done_Face(m_face);
|
||||
}
|
||||
|
||||
GpFontHandler_FreeType2 *GpFontHandler_FreeType2::Create()
|
||||
{
|
||||
void *storage = malloc(sizeof(GpFontHandler_FreeType2));
|
||||
if (!storage)
|
||||
return nullptr;
|
||||
|
||||
GpFontHandler_FreeType2 *fh = new (storage) GpFontHandler_FreeType2();
|
||||
if (!fh->Init())
|
||||
{
|
||||
fh->Shutdown();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return fh;
|
||||
}
|
||||
|
||||
PortabilityLayer::HostFont *GpFontHandler_FreeType2::LoadFont(PortabilityLayer::IOStream *stream)
|
||||
{
|
||||
|
||||
FT_StreamRec_ ftStream;
|
||||
memset(&ftStream, 0, sizeof(ftStream));
|
||||
ftStream.size = 0x7fffffff;
|
||||
ftStream.pos = 0;
|
||||
ftStream.descriptor.pointer = stream;
|
||||
ftStream.read = FTStreamIo;
|
||||
ftStream.close = FTStreamClose;
|
||||
|
||||
FT_Open_Args openArgs;
|
||||
memset(&openArgs, 0, sizeof(openArgs));
|
||||
openArgs.flags = FT_OPEN_STREAM;
|
||||
openArgs.stream = &ftStream;
|
||||
|
||||
FT_Face face;
|
||||
FT_Error errorCode = FT_Open_Face(m_library, &openArgs, 0, &face);
|
||||
if (errorCode != 0)
|
||||
return nullptr;
|
||||
|
||||
GpFont_FreeType2 *font = GpFont_FreeType2::Create(face);
|
||||
if (!font)
|
||||
{
|
||||
FT_Done_Face(face);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
void GpFontHandler_FreeType2::Shutdown()
|
||||
{
|
||||
this->~GpFontHandler_FreeType2();
|
||||
free(this);
|
||||
}
|
||||
|
||||
GpFontHandler_FreeType2::GpFontHandler_FreeType2()
|
||||
: m_ftIsInitialized(false)
|
||||
, m_library(nullptr)
|
||||
, m_currentSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
GpFontHandler_FreeType2::~GpFontHandler_FreeType2()
|
||||
{
|
||||
if (m_ftIsInitialized)
|
||||
FT_Done_Library(m_library);
|
||||
}
|
||||
|
||||
|
||||
void *GpFontHandler_FreeType2::FTAllocThunk(FT_Memory memory, long size)
|
||||
{
|
||||
return static_cast<GpFontHandler_FreeType2*>(memory->user)->FTAlloc(size);
|
||||
}
|
||||
|
||||
void GpFontHandler_FreeType2::FTFreeThunk(FT_Memory memory, void* block)
|
||||
{
|
||||
static_cast<GpFontHandler_FreeType2*>(memory->user)->FTFree(block);
|
||||
}
|
||||
|
||||
void *GpFontHandler_FreeType2::FTReallocThunk(FT_Memory memory, long curSize, long newSize, void *block)
|
||||
{
|
||||
return static_cast<GpFontHandler_FreeType2*>(memory->user)->FTRealloc(curSize, newSize, block);
|
||||
}
|
||||
|
||||
|
||||
unsigned long GpFontHandler_FreeType2::FTStreamIo(FT_Stream stream, unsigned long offset, unsigned char* buffer, unsigned long count)
|
||||
{
|
||||
PortabilityLayer::IOStream *ioStream = static_cast<PortabilityLayer::IOStream*>(stream->descriptor.pointer);
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
if (!ioStream->SeekStart(static_cast<PortabilityLayer::UFilePos_t>(offset)))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const size_t bytesRead = ioStream->Read(buffer, count);
|
||||
return static_cast<unsigned long>(bytesRead);
|
||||
}
|
||||
|
||||
void GpFontHandler_FreeType2::FTStreamClose(FT_Stream stream)
|
||||
{
|
||||
(void)stream;
|
||||
}
|
||||
|
||||
void *GpFontHandler_FreeType2::FTAlloc(long size)
|
||||
{
|
||||
return malloc(static_cast<size_t>(size));
|
||||
}
|
||||
|
||||
void GpFontHandler_FreeType2::FTFree(void* block)
|
||||
{
|
||||
free(block);
|
||||
}
|
||||
|
||||
void *GpFontHandler_FreeType2::FTRealloc(long curSize, long newSize, void *block)
|
||||
{
|
||||
(void)curSize;
|
||||
return realloc(block, static_cast<size_t>(newSize));
|
||||
}
|
||||
|
||||
bool GpFontHandler_FreeType2::Init()
|
||||
{
|
||||
m_mem.user = this;
|
||||
m_mem.alloc = FTAllocThunk;
|
||||
m_mem.free = FTFreeThunk;
|
||||
m_mem.realloc = FTReallocThunk;
|
||||
|
||||
if (FT_New_Library(&m_mem, &m_library) != 0)
|
||||
return false;
|
||||
|
||||
m_ftIsInitialized = true;
|
||||
|
||||
FT_Add_Default_Modules(m_library);
|
||||
|
||||
return true;
|
||||
}
|
||||
44
GpD3D/GpFontHandler_FreeType2.h
Normal file
44
GpD3D/GpFontHandler_FreeType2.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include "HostFontHandler.h"
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_SYSTEM_H
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
class IOStream;
|
||||
class HostFont;
|
||||
}
|
||||
|
||||
class GpFontHandler_FreeType2 final : public PortabilityLayer::HostFontHandler
|
||||
{
|
||||
public:
|
||||
PortabilityLayer::HostFont *LoadFont(PortabilityLayer::IOStream *stream) override;
|
||||
void Shutdown() override;
|
||||
|
||||
static GpFontHandler_FreeType2 *Create();
|
||||
|
||||
private:
|
||||
GpFontHandler_FreeType2();
|
||||
~GpFontHandler_FreeType2();
|
||||
|
||||
static void *FTAllocThunk(FT_Memory memory, long size);
|
||||
static void FTFreeThunk(FT_Memory memory, void* block);
|
||||
static void *FTReallocThunk(FT_Memory memory, long curSize, long newSize, void *block);
|
||||
|
||||
static unsigned long FTStreamIo(FT_Stream stream, unsigned long offset, unsigned char* buffer, unsigned long count);
|
||||
static void FTStreamClose(FT_Stream stream);
|
||||
|
||||
void *FTAlloc(long size);
|
||||
void FTFree(void* block);
|
||||
void *FTRealloc(long curSize, long newSize, void *block);
|
||||
|
||||
bool Init();
|
||||
|
||||
FT_MemoryRec_ m_mem;
|
||||
FT_Library m_library;
|
||||
unsigned int m_currentSize;
|
||||
bool m_ftIsInitialized;
|
||||
};
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "GpMain.h"
|
||||
#include "GpAudioDriverFactory.h"
|
||||
#include "GpAudioDriverProperties.h"
|
||||
#include "GpFontHandlerFactory.h"
|
||||
#include "GpDisplayDriverFactory.h"
|
||||
#include "GpDisplayDriverProperties.h"
|
||||
#include "GpGlobalConfig.h"
|
||||
@@ -16,6 +17,11 @@ namespace
|
||||
{
|
||||
static_cast<GpAppEnvironment*>(context)->Tick(vosFiber);
|
||||
}
|
||||
|
||||
void RenderAppEnvironment(void *context)
|
||||
{
|
||||
static_cast<GpAppEnvironment*>(context)->Render();
|
||||
}
|
||||
}
|
||||
|
||||
int GpMain::Run()
|
||||
@@ -38,6 +44,10 @@ int GpMain::Run()
|
||||
|
||||
ddProps.m_tickFunc = TickAppEnvironment;
|
||||
ddProps.m_tickFuncContext = appEnvironment;
|
||||
|
||||
ddProps.m_renderFunc = RenderAppEnvironment;
|
||||
ddProps.m_renderFuncContext = appEnvironment;
|
||||
|
||||
ddProps.m_type = g_gpGlobalConfig.m_displayDriverType;
|
||||
|
||||
GpAudioDriverProperties adProps;
|
||||
@@ -51,11 +61,13 @@ int GpMain::Run()
|
||||
|
||||
IGpDisplayDriver *displayDriver = GpDisplayDriverFactory::CreateDisplayDriver(ddProps);
|
||||
IGpAudioDriver *audioDriver = GpAudioDriverFactory::CreateAudioDriver(adProps);
|
||||
PortabilityLayer::HostFontHandler *fontHandler = GpFontHandlerFactory::Create();
|
||||
|
||||
appEnvironment->Init();
|
||||
|
||||
appEnvironment->SetDisplayDriver(displayDriver);
|
||||
appEnvironment->SetAudioDriver(audioDriver);
|
||||
appEnvironment->SetFontHandler(fontHandler);
|
||||
|
||||
// Start the display loop
|
||||
displayDriver->Run();
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "HostAudioDriver.h"
|
||||
|
||||
class IGpAudioDriver;
|
||||
|
||||
class GpPLGlueAudioDriver final : public PortabilityLayer::HostAudioDriver
|
||||
{
|
||||
public:
|
||||
#pragma once
|
||||
|
||||
#include "HostAudioDriver.h"
|
||||
|
||||
struct IGpAudioDriver;
|
||||
|
||||
class GpPLGlueAudioDriver final : public PortabilityLayer::HostAudioDriver
|
||||
{
|
||||
public:
|
||||
GpPLGlueAudioDriver();
|
||||
|
||||
PortabilityLayer::HostAudioChannel *CreateChannel() override;
|
||||
|
||||
void SetGpAudioDriver(IGpAudioDriver *audioDriver);
|
||||
|
||||
static GpPLGlueAudioDriver *GetInstance();
|
||||
|
||||
private:
|
||||
IGpAudioDriver *m_audioDriver;
|
||||
|
||||
static GpPLGlueAudioDriver ms_instance;
|
||||
};
|
||||
PortabilityLayer::HostAudioChannel *CreateChannel() override;
|
||||
|
||||
void SetGpAudioDriver(IGpAudioDriver *audioDriver);
|
||||
|
||||
static GpPLGlueAudioDriver *GetInstance();
|
||||
|
||||
private:
|
||||
IGpAudioDriver *m_audioDriver;
|
||||
|
||||
static GpPLGlueAudioDriver ms_instance;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "HostDisplayDriver.h"
|
||||
|
||||
class IGpDisplayDriver;
|
||||
struct IGpDisplayDriver;
|
||||
|
||||
class GpPLGlueDisplayDriver final : public PortabilityLayer::HostDisplayDriver
|
||||
{
|
||||
|
||||
45
GpD3D/GpVOSEventQueue.cpp
Normal file
45
GpD3D/GpVOSEventQueue.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "GpVOSEventQueue.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
GpVOSEventQueue::GpVOSEventQueue()
|
||||
: m_firstEvent(0)
|
||||
, m_numEventsQueued(0)
|
||||
{
|
||||
}
|
||||
|
||||
GpVOSEventQueue::~GpVOSEventQueue()
|
||||
{
|
||||
}
|
||||
|
||||
const GpVOSEvent *GpVOSEventQueue::GetNext()
|
||||
{
|
||||
if (m_numEventsQueued)
|
||||
return m_events + m_firstEvent;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GpVOSEventQueue::DischargeOne()
|
||||
{
|
||||
assert(m_numEventsQueued > 0);
|
||||
|
||||
m_numEventsQueued--;
|
||||
m_firstEvent++;
|
||||
if (m_firstEvent == kMaxEvents)
|
||||
m_firstEvent = 0;
|
||||
}
|
||||
|
||||
GpVOSEvent *GpVOSEventQueue::QueueEvent()
|
||||
{
|
||||
if (m_numEventsQueued == kMaxEvents)
|
||||
return nullptr;
|
||||
|
||||
size_t nextEvent = m_firstEvent + m_numEventsQueued;
|
||||
if (nextEvent >= kMaxEvents)
|
||||
nextEvent -= kMaxEvents;
|
||||
|
||||
m_numEventsQueued++;
|
||||
|
||||
return m_events + nextEvent;
|
||||
}
|
||||
25
GpD3D/GpVOSEventQueue.h
Normal file
25
GpD3D/GpVOSEventQueue.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "HostVOSEventQueue.h"
|
||||
#include "GpVOSEvent.h"
|
||||
|
||||
class GpVOSEventQueue final : public PortabilityLayer::HostVOSEventQueue
|
||||
{
|
||||
public:
|
||||
GpVOSEventQueue();
|
||||
~GpVOSEventQueue();
|
||||
|
||||
const GpVOSEvent *GetNext() override;
|
||||
void DischargeOne() override;
|
||||
|
||||
GpVOSEvent *QueueEvent();
|
||||
|
||||
private:
|
||||
static const size_t kMaxEvents = 10000;
|
||||
|
||||
GpVOSEvent m_events[kMaxEvents];
|
||||
size_t m_firstEvent;
|
||||
size_t m_numEventsQueued;
|
||||
};
|
||||
52
GpD3D/ShadersD3D11/DrawQuad15BitP_D3D11.cpp
Normal file
52
GpD3D/ShadersD3D11/DrawQuad15BitP_D3D11.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
static unsigned char gs_shaderData[] = {
|
||||
68, 88, 66, 67, 181, 133, 124, 121, 179, 141, 64, 216, 166, 21, 153,
|
||||
10, 33, 21, 80, 169, 1, 0, 0, 0, 152, 2, 0, 0, 5, 0,
|
||||
0, 0, 52, 0, 0, 0, 224, 0, 0, 0, 56, 1, 0, 0, 108,
|
||||
1, 0, 0, 28, 2, 0, 0, 82, 68, 69, 70, 164, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 28, 0, 0,
|
||||
0, 0, 4, 255, 255, 0, 137, 0, 0, 122, 0, 0, 0, 92, 0,
|
||||
0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
|
||||
107, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 4, 0, 0,
|
||||
0, 255, 255, 255, 255, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,
|
||||
0, 0, 115, 117, 114, 102, 97, 99, 101, 83, 97, 109, 112, 108, 101,
|
||||
114, 0, 115, 117, 114, 102, 97, 99, 101, 84, 101, 120, 116, 117, 114,
|
||||
101, 0, 77, 105, 99, 114, 111, 115, 111, 102, 116, 32, 40, 82, 41,
|
||||
32, 72, 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111,
|
||||
109, 112, 105, 108, 101, 114, 32, 49, 48, 46, 49, 0, 171, 171, 73,
|
||||
83, 71, 78, 80, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0,
|
||||
56, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0,
|
||||
0, 0, 0, 0, 0, 15, 0, 0, 0, 68, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3,
|
||||
3, 0, 0, 83, 86, 95, 80, 79, 83, 73, 84, 73, 79, 78, 0,
|
||||
84, 69, 88, 67, 79, 79, 82, 68, 0, 171, 171, 171, 79, 83, 71,
|
||||
78, 44, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 32, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0,
|
||||
0, 0, 0, 15, 0, 0, 0, 83, 86, 95, 84, 65, 82, 71, 69,
|
||||
84, 0, 171, 171, 83, 72, 68, 82, 168, 0, 0, 0, 64, 0, 0,
|
||||
0, 42, 0, 0, 0, 90, 0, 0, 3, 0, 96, 16, 0, 0, 0,
|
||||
0, 0, 88, 24, 0, 4, 0, 112, 16, 0, 0, 0, 0, 0, 85,
|
||||
85, 0, 0, 98, 16, 0, 3, 50, 16, 16, 0, 1, 0, 0, 0,
|
||||
101, 0, 0, 3, 242, 32, 16, 0, 0, 0, 0, 0, 104, 0, 0,
|
||||
2, 1, 0, 0, 0, 69, 0, 0, 9, 242, 0, 16, 0, 0, 0,
|
||||
0, 0, 70, 16, 16, 0, 1, 0, 0, 0, 70, 126, 16, 0, 0,
|
||||
0, 0, 0, 0, 96, 16, 0, 0, 0, 0, 0, 54, 0, 0, 5,
|
||||
18, 32, 16, 0, 0, 0, 0, 0, 10, 0, 16, 0, 0, 0, 0,
|
||||
0, 54, 0, 0, 5, 98, 32, 16, 0, 0, 0, 0, 0, 6, 17,
|
||||
16, 0, 1, 0, 0, 0, 54, 0, 0, 5, 130, 32, 16, 0, 0,
|
||||
0, 0, 0, 1, 64, 0, 0, 0, 0, 128, 63, 62, 0, 0, 1,
|
||||
83, 84, 65, 84, 116, 0, 0, 0, 5, 0, 0, 0, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
};
|
||||
|
||||
namespace GpBinarizedShaders
|
||||
{
|
||||
const unsigned char *g_drawQuad15BitP_D3D11[2] = { gs_shaderData, gs_shaderData + sizeof(gs_shaderData) };
|
||||
};
|
||||
58
GpD3D/ShadersD3D11/DrawQuadPaletteP_D3D11.cpp
Normal file
58
GpD3D/ShadersD3D11/DrawQuadPaletteP_D3D11.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
static unsigned char gs_shaderData[] = {
|
||||
68, 88, 66, 67, 96, 46, 192, 91, 73, 216, 92, 145, 77, 166, 215,
|
||||
215, 59, 255, 4, 67, 1, 0, 0, 0, 240, 2, 0, 0, 5, 0,
|
||||
0, 0, 52, 0, 0, 0, 224, 0, 0, 0, 56, 1, 0, 0, 108,
|
||||
1, 0, 0, 116, 2, 0, 0, 82, 68, 69, 70, 164, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 28, 0, 0,
|
||||
0, 0, 4, 255, 255, 0, 137, 0, 0, 122, 0, 0, 0, 92, 0,
|
||||
0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 255,
|
||||
255, 255, 255, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
|
||||
107, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 2, 0, 0,
|
||||
0, 255, 255, 255, 255, 1, 0, 0, 0, 1, 0, 0, 0, 13, 0,
|
||||
0, 0, 115, 117, 114, 102, 97, 99, 101, 84, 101, 120, 116, 117, 114,
|
||||
101, 0, 112, 97, 108, 101, 116, 116, 101, 84, 101, 120, 116, 117, 114,
|
||||
101, 0, 77, 105, 99, 114, 111, 115, 111, 102, 116, 32, 40, 82, 41,
|
||||
32, 72, 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111,
|
||||
109, 112, 105, 108, 101, 114, 32, 49, 48, 46, 49, 0, 171, 171, 73,
|
||||
83, 71, 78, 80, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0,
|
||||
56, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0,
|
||||
0, 0, 0, 0, 0, 15, 0, 0, 0, 68, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3,
|
||||
3, 0, 0, 83, 86, 95, 80, 79, 83, 73, 84, 73, 79, 78, 0,
|
||||
84, 69, 88, 67, 79, 79, 82, 68, 0, 171, 171, 171, 79, 83, 71,
|
||||
78, 44, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 32, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0,
|
||||
0, 0, 0, 15, 0, 0, 0, 83, 86, 95, 84, 65, 82, 71, 69,
|
||||
84, 0, 171, 171, 83, 72, 68, 82, 0, 1, 0, 0, 64, 0, 0,
|
||||
0, 64, 0, 0, 0, 88, 24, 0, 4, 0, 112, 16, 0, 0, 0,
|
||||
0, 0, 68, 68, 0, 0, 88, 16, 0, 4, 0, 112, 16, 0, 1,
|
||||
0, 0, 0, 85, 85, 0, 0, 98, 16, 0, 3, 50, 16, 16, 0,
|
||||
1, 0, 0, 0, 101, 0, 0, 3, 242, 32, 16, 0, 0, 0, 0,
|
||||
0, 104, 0, 0, 2, 1, 0, 0, 0, 27, 0, 0, 5, 50, 0,
|
||||
16, 0, 0, 0, 0, 0, 70, 16, 16, 0, 1, 0, 0, 0, 54,
|
||||
0, 0, 8, 194, 0, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 45, 0, 0, 7, 242, 0, 16, 0, 0, 0, 0, 0, 70, 14,
|
||||
16, 0, 0, 0, 0, 0, 70, 126, 16, 0, 0, 0, 0, 0, 54,
|
||||
0, 0, 8, 226, 0, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 45, 0, 0, 7, 242, 0, 16, 0, 0, 0, 0, 0, 70, 14,
|
||||
16, 0, 0, 0, 0, 0, 70, 126, 16, 0, 1, 0, 0, 0, 54,
|
||||
0, 0, 5, 114, 32, 16, 0, 0, 0, 0, 0, 70, 2, 16, 0,
|
||||
0, 0, 0, 0, 54, 0, 0, 5, 130, 32, 16, 0, 0, 0, 0,
|
||||
0, 1, 64, 0, 0, 0, 0, 128, 63, 62, 0, 0, 1, 83, 84,
|
||||
65, 84, 116, 0, 0, 0, 8, 0, 0, 0, 1, 0, 0, 0, 0,
|
||||
0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0,
|
||||
};
|
||||
|
||||
namespace GpBinarizedShaders
|
||||
{
|
||||
const unsigned char *g_drawQuadPaletteP_D3D11[2] = { gs_shaderData, gs_shaderData + sizeof(gs_shaderData) };
|
||||
};
|
||||
52
GpD3D/ShadersD3D11/DrawQuadRGBP_D3D11.cpp
Normal file
52
GpD3D/ShadersD3D11/DrawQuadRGBP_D3D11.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
static unsigned char gs_shaderData[] = {
|
||||
68, 88, 66, 67, 181, 133, 124, 121, 179, 141, 64, 216, 166, 21, 153,
|
||||
10, 33, 21, 80, 169, 1, 0, 0, 0, 152, 2, 0, 0, 5, 0,
|
||||
0, 0, 52, 0, 0, 0, 224, 0, 0, 0, 56, 1, 0, 0, 108,
|
||||
1, 0, 0, 28, 2, 0, 0, 82, 68, 69, 70, 164, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 28, 0, 0,
|
||||
0, 0, 4, 255, 255, 0, 137, 0, 0, 122, 0, 0, 0, 92, 0,
|
||||
0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
|
||||
107, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 4, 0, 0,
|
||||
0, 255, 255, 255, 255, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,
|
||||
0, 0, 115, 117, 114, 102, 97, 99, 101, 83, 97, 109, 112, 108, 101,
|
||||
114, 0, 115, 117, 114, 102, 97, 99, 101, 84, 101, 120, 116, 117, 114,
|
||||
101, 0, 77, 105, 99, 114, 111, 115, 111, 102, 116, 32, 40, 82, 41,
|
||||
32, 72, 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111,
|
||||
109, 112, 105, 108, 101, 114, 32, 49, 48, 46, 49, 0, 171, 171, 73,
|
||||
83, 71, 78, 80, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0,
|
||||
56, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0,
|
||||
0, 0, 0, 0, 0, 15, 0, 0, 0, 68, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 3,
|
||||
3, 0, 0, 83, 86, 95, 80, 79, 83, 73, 84, 73, 79, 78, 0,
|
||||
84, 69, 88, 67, 79, 79, 82, 68, 0, 171, 171, 171, 79, 83, 71,
|
||||
78, 44, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 32, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0,
|
||||
0, 0, 0, 15, 0, 0, 0, 83, 86, 95, 84, 65, 82, 71, 69,
|
||||
84, 0, 171, 171, 83, 72, 68, 82, 168, 0, 0, 0, 64, 0, 0,
|
||||
0, 42, 0, 0, 0, 90, 0, 0, 3, 0, 96, 16, 0, 0, 0,
|
||||
0, 0, 88, 24, 0, 4, 0, 112, 16, 0, 0, 0, 0, 0, 85,
|
||||
85, 0, 0, 98, 16, 0, 3, 50, 16, 16, 0, 1, 0, 0, 0,
|
||||
101, 0, 0, 3, 242, 32, 16, 0, 0, 0, 0, 0, 104, 0, 0,
|
||||
2, 1, 0, 0, 0, 69, 0, 0, 9, 242, 0, 16, 0, 0, 0,
|
||||
0, 0, 70, 16, 16, 0, 1, 0, 0, 0, 70, 126, 16, 0, 0,
|
||||
0, 0, 0, 0, 96, 16, 0, 0, 0, 0, 0, 54, 0, 0, 5,
|
||||
18, 32, 16, 0, 0, 0, 0, 0, 10, 0, 16, 0, 0, 0, 0,
|
||||
0, 54, 0, 0, 5, 98, 32, 16, 0, 0, 0, 0, 0, 6, 17,
|
||||
16, 0, 1, 0, 0, 0, 54, 0, 0, 5, 130, 32, 16, 0, 0,
|
||||
0, 0, 0, 1, 64, 0, 0, 0, 0, 128, 63, 62, 0, 0, 1,
|
||||
83, 84, 65, 84, 116, 0, 0, 0, 5, 0, 0, 0, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
};
|
||||
|
||||
namespace GpBinarizedShaders
|
||||
{
|
||||
const unsigned char *g_drawQuadRGBP_D3D11[2] = { gs_shaderData, gs_shaderData + sizeof(gs_shaderData) };
|
||||
};
|
||||
59
GpD3D/ShadersD3D11/DrawQuadV_D3D11.cpp
Normal file
59
GpD3D/ShadersD3D11/DrawQuadV_D3D11.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
static unsigned char gs_shaderData[] = {
|
||||
68, 88, 66, 67, 201, 152, 69, 241, 255, 40, 36, 8, 50, 11, 168,
|
||||
246, 127, 135, 38, 130, 1, 0, 0, 0, 8, 3, 0, 0, 5, 0,
|
||||
0, 0, 52, 0, 0, 0, 72, 1, 0, 0, 124, 1, 0, 0, 212,
|
||||
1, 0, 0, 140, 2, 0, 0, 82, 68, 69, 70, 12, 1, 0, 0,
|
||||
1, 0, 0, 0, 88, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0,
|
||||
0, 0, 4, 254, 255, 0, 137, 0, 0, 225, 0, 0, 0, 60, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
|
||||
83, 68, 114, 97, 119, 81, 117, 97, 100, 86, 101, 114, 116, 101, 120,
|
||||
67, 111, 110, 115, 116, 97, 110, 116, 115, 0, 171, 171, 171, 60, 0,
|
||||
0, 0, 2, 0, 0, 0, 112, 0, 0, 0, 32, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 160, 0, 0, 0, 0, 0, 0, 0,
|
||||
16, 0, 0, 0, 2, 0, 0, 0, 184, 0, 0, 0, 0, 0, 0,
|
||||
0, 200, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 2, 0,
|
||||
0, 0, 184, 0, 0, 0, 0, 0, 0, 0, 110, 100, 99, 79, 114,
|
||||
105, 103, 105, 110, 65, 110, 100, 68, 105, 109, 101, 110, 115, 105, 111,
|
||||
110, 115, 0, 171, 1, 0, 3, 0, 1, 0, 4, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 115, 117, 114, 102, 97, 99, 101, 68, 105, 109,
|
||||
101, 110, 115, 105, 111, 110, 115, 95, 85, 110, 117, 115, 101, 100, 0,
|
||||
77, 105, 99, 114, 111, 115, 111, 102, 116, 32, 40, 82, 41, 32, 72,
|
||||
76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112,
|
||||
105, 108, 101, 114, 32, 49, 48, 46, 49, 0, 171, 171, 171, 73, 83,
|
||||
71, 78, 44, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 32,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0,
|
||||
0, 0, 0, 0, 3, 3, 0, 0, 80, 79, 83, 73, 84, 73, 79,
|
||||
78, 0, 171, 171, 171, 79, 83, 71, 78, 80, 0, 0, 0, 2, 0,
|
||||
0, 0, 8, 0, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 1,
|
||||
0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0,
|
||||
68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0,
|
||||
0, 1, 0, 0, 0, 3, 12, 0, 0, 83, 86, 95, 80, 79, 83,
|
||||
73, 84, 73, 79, 78, 0, 84, 69, 88, 67, 79, 79, 82, 68, 0,
|
||||
171, 171, 171, 83, 72, 68, 82, 176, 0, 0, 0, 64, 0, 1, 0,
|
||||
44, 0, 0, 0, 89, 0, 0, 4, 70, 142, 32, 0, 0, 0, 0,
|
||||
0, 2, 0, 0, 0, 95, 0, 0, 3, 50, 16, 16, 0, 0, 0,
|
||||
0, 0, 103, 0, 0, 4, 242, 32, 16, 0, 0, 0, 0, 0, 1,
|
||||
0, 0, 0, 101, 0, 0, 3, 50, 32, 16, 0, 1, 0, 0, 0,
|
||||
50, 0, 0, 11, 50, 32, 16, 0, 0, 0, 0, 0, 70, 16, 16,
|
||||
0, 0, 0, 0, 0, 230, 138, 32, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 70, 128, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54,
|
||||
0, 0, 8, 194, 32, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128,
|
||||
63, 56, 0, 0, 8, 50, 32, 16, 0, 1, 0, 0, 0, 70, 16,
|
||||
16, 0, 0, 0, 0, 0, 70, 128, 32, 0, 0, 0, 0, 0, 1,
|
||||
0, 0, 0, 62, 0, 0, 1, 83, 84, 65, 84, 116, 0, 0, 0,
|
||||
4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0,
|
||||
0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
namespace GpBinarizedShaders
|
||||
{
|
||||
const unsigned char *g_drawQuadV_D3D11[2] = { gs_shaderData, gs_shaderData + sizeof(gs_shaderData) };
|
||||
};
|
||||
Reference in New Issue
Block a user