2024-11-01 16:55:46 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "Unity/IUnityGraphics.h"
|
|
|
|
|
|
2024-11-22 12:09:31 +08:00
|
|
|
#include <array>
|
2024-11-01 16:55:46 +08:00
|
|
|
|
|
|
|
|
struct IUnityInterfaces;
|
|
|
|
|
|
2024-11-22 12:09:31 +08:00
|
|
|
enum GraphicsFeature
|
|
|
|
|
{
|
|
|
|
|
VRS_DRAW = 0,
|
|
|
|
|
VRS_PRIMITIVE,
|
|
|
|
|
VRS_ATTACHMENT,
|
|
|
|
|
HW_SPATIAL_SR,
|
|
|
|
|
HW_AISR,
|
|
|
|
|
HW_ADAPTIVE_VRS,
|
|
|
|
|
HW_FG_INTERPOLATE,
|
|
|
|
|
HW_FG_EXTRAPOLATION,
|
|
|
|
|
METAL_FX_SPATIAL_SR,
|
|
|
|
|
METAL_FX_TEMPORAL_SR,
|
|
|
|
|
VIVO_TEMPORAL_SR,
|
|
|
|
|
QCOM_AFME,
|
2024-12-11 17:42:08 +08:00
|
|
|
XESS13,
|
2024-11-22 12:09:31 +08:00
|
|
|
MAX_CNT
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct SupportFeatureList
|
|
|
|
|
{
|
|
|
|
|
std::array<bool, GraphicsFeature::MAX_CNT> support_features = {0};
|
|
|
|
|
|
|
|
|
|
bool& operator[](GraphicsFeature feature)
|
|
|
|
|
{
|
|
|
|
|
return support_features[(int)feature];
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct AFMEParam
|
|
|
|
|
{
|
|
|
|
|
void* src;
|
|
|
|
|
void* data;
|
|
|
|
|
void* dst;
|
|
|
|
|
};
|
|
|
|
|
|
2024-11-01 16:55:46 +08:00
|
|
|
// Super-simple "graphics abstraction". This is nothing like how a proper platform abstraction layer would look like;
|
|
|
|
|
// all this does is a base interface for whatever our plugin sample needs. Which is only "draw some triangles"
|
|
|
|
|
// and "modify a texture" at this point.
|
|
|
|
|
//
|
|
|
|
|
// There are implementations of this base class for D3D9, D3D11, OpenGL etc.; see individual RenderAPI_* files.
|
|
|
|
|
class RenderAPI
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
virtual ~RenderAPI() { }
|
|
|
|
|
|
|
|
|
|
// Process general event like initialization, shutdown, device loss/reset etc.
|
2024-11-22 12:09:31 +08:00
|
|
|
virtual void processDeviceEvent(UnityGfxDeviceEventType type, IUnityInterfaces* interfaces) = 0;
|
2024-11-01 16:55:46 +08:00
|
|
|
|
|
|
|
|
// Is the API using "reversed" (1.0 at near plane, 0.0 at far plane) depth buffer?
|
|
|
|
|
// Reversed Z is used on modern platforms, and improves depth buffer precision.
|
2024-11-22 12:09:31 +08:00
|
|
|
virtual bool getUsesReverseZ() = 0;
|
2024-11-01 16:55:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
// Sets the underlying resource to unity RenderBuffer
|
|
|
|
|
// see https://docs.unity3d.com/ScriptReference/RenderBuffer.html
|
|
|
|
|
// setting rb to nullptr is used to signal the plugin that the
|
|
|
|
|
// previously set RenderBuffer is no longer valid
|
|
|
|
|
virtual void setRenderTextureResource(UnityRenderBuffer rb) {}
|
|
|
|
|
|
|
|
|
|
// This should return true when the plugin is used with the unity player
|
|
|
|
|
// and false when the editor is used. The editor uses multiple swap
|
|
|
|
|
// chains (for each window) so instead of choosing one of them nullptr is returned.
|
|
|
|
|
virtual bool isSwapChainAvailable() { return false; };
|
|
|
|
|
|
|
|
|
|
// These require the swap chain to be available to be functional.
|
|
|
|
|
// When the swap chain is not available these simply return 0
|
|
|
|
|
|
|
|
|
|
virtual unsigned int getPresentFlags() { return 0; }
|
|
|
|
|
virtual unsigned int getSyncInterval() { return 0; }
|
2024-11-22 12:09:31 +08:00
|
|
|
virtual unsigned int getBackbufferWidth() { return 0; }
|
2024-11-01 16:55:46 +08:00
|
|
|
virtual unsigned int getBackbufferHeight() { return 0; }
|
|
|
|
|
|
|
|
|
|
virtual void enableVRS(int vrsEnum) {}
|
|
|
|
|
virtual void disableVRS() {}
|
2024-11-22 12:09:31 +08:00
|
|
|
|
2024-11-22 14:45:23 +08:00
|
|
|
virtual void enableFGExtrapolation(void* data) {}
|
2024-11-22 12:09:31 +08:00
|
|
|
virtual void preFGExtrapolation() {}
|
|
|
|
|
// when renturn true present dst, data may matriaxs or texture
|
|
|
|
|
virtual bool doFGExtrapolation(void* src, void* data, void* dst) { return false;}
|
|
|
|
|
virtual void postFGExtrapolation() {}
|
|
|
|
|
virtual void disableFGExtrapolation() {}
|
|
|
|
|
|
2024-12-17 20:50:36 +08:00
|
|
|
virtual void spatialUpScale(void* data) {}
|
2024-11-22 12:09:31 +08:00
|
|
|
|
|
|
|
|
virtual bool getFeatureSupport(GraphicsFeature feature);
|
2024-12-12 17:41:33 +08:00
|
|
|
|
|
|
|
|
virtual void enableXESS1(void* data) {}
|
|
|
|
|
virtual void doXESS1(void* data) {}
|
|
|
|
|
virtual void configXESS1(void* data) {}
|
|
|
|
|
virtual void disableXESS1() {}
|
|
|
|
|
|
2024-12-16 20:33:34 +08:00
|
|
|
virtual bool getInputResolution(uint32_t outw, uint32_t outh, int quality, uint32_t& width, uint32_t& height) { return false; }
|
2024-11-22 12:09:31 +08:00
|
|
|
protected:
|
|
|
|
|
virtual void initSupportFeature() = 0;
|
|
|
|
|
|
|
|
|
|
SupportFeatureList support_features;
|
2024-11-01 16:55:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create a graphics API implementation instance for the given API type.
|
2024-11-22 12:09:31 +08:00
|
|
|
RenderAPI* createRenderAPI(UnityGfxRenderer apiType);
|
2024-11-01 16:55:46 +08:00
|
|
|
|