#include "RenderAPI.h" #include "PlatformBase.h" // Direct3D 11 implementation of RenderAPI. #if SUPPORT_D3D11 #include #include #include "Unity/IUnityGraphicsD3D11.h" class RenderAPI_D3D11 : public RenderAPI { public: RenderAPI_D3D11(); virtual ~RenderAPI_D3D11() { } virtual void processDeviceEvent(UnityGfxDeviceEventType type, IUnityInterfaces* interfaces); virtual bool getUsesReverseZ() { return (int)m_Device->GetFeatureLevel() >= (int)D3D_FEATURE_LEVEL_10_0; } virtual void initSupportFeature() override; private: ID3D11Device* m_Device; }; RenderAPI* CreateRenderAPI_D3D11() { return new RenderAPI_D3D11(); } // Simple compiled shader bytecode. // // Shader source that was used: #if 0 cbuffer MyCB : register(b0) { float4x4 worldMatrix; } void VS(float3 pos : POSITION, float4 color : COLOR, out float4 ocolor : COLOR, out float4 opos : SV_Position) { opos = mul(worldMatrix, float4(pos, 1)); ocolor = color; } float4 PS(float4 color : COLOR) : SV_TARGET { return color; } #endif // #if 0 // // Which then was compiled with: // fxc /Tvs_4_0_level_9_3 /EVS source.hlsl /Fh outVS.h /Qstrip_reflect /Qstrip_debug /Qstrip_priv // fxc /Tps_4_0_level_9_3 /EPS source.hlsl /Fh outPS.h /Qstrip_reflect /Qstrip_debug /Qstrip_priv // and results pasted & formatted to take less lines here RenderAPI_D3D11::RenderAPI_D3D11() : m_Device(NULL) { } void RenderAPI_D3D11::processDeviceEvent(UnityGfxDeviceEventType type, IUnityInterfaces* interfaces) { switch (type) { case kUnityGfxDeviceEventInitialize: { IUnityGraphicsD3D11* d3d = interfaces->Get(); m_Device = d3d->GetDevice(); break; } case kUnityGfxDeviceEventShutdown: break; } } void RenderAPI_D3D11::initSupportFeature() { } #endif // #if SUPPORT_D3D11