Effekseer
EffekseerRendererDX12.h
1 
2 #ifndef __EFFEKSEERRENDERER_DX12_BASE_PRE_H__
3 #define __EFFEKSEERRENDERER_DX12_BASE_PRE_H__
4 
5 #include <Effekseer.h>
6 #include <d3d12.h>
7 
8 namespace EffekseerRendererDX12
9 {
10 
11 }
12 
13 #endif
14 
15 #ifndef __EFFEKSEERRENDERER_RENDERER_H__
16 #define __EFFEKSEERRENDERER_RENDERER_H__
17 
18 //----------------------------------------------------------------------------------
19 // Include
20 //----------------------------------------------------------------------------------
21 #include <Effekseer.h>
22 
23 //-----------------------------------------------------------------------------------
24 //
25 //-----------------------------------------------------------------------------------
26 
27 namespace Effekseer
28 {
29 namespace Backend
30 {
31 class VertexBuffer;
32 class IndexBuffer;
33 class GraphicsDevice;
34 } // namespace Backend
35 } // namespace Effekseer
36 
37 namespace EffekseerRenderer
38 {
39 
40 class Renderer;
41 using RendererRef = ::Effekseer::RefPtr<Renderer>;
42 
48 struct ExternalShaderSettings
49 {
50  Effekseer::Backend::ShaderRef StandardShader;
51  Effekseer::Backend::ShaderRef ModelShader;
52  Effekseer::AlphaBlendType Blend;
53 };
54 
61 class DistortingCallback
62 {
63 public:
64  DistortingCallback()
65  {
66  }
67  virtual ~DistortingCallback()
68  {
69  }
70 
79  virtual bool OnDistorting(Renderer* renderer)
80  {
81  return false;
82  }
83 };
84 
90 enum class UVStyle
91 {
92  Normal,
93  VerticalFlipped,
94 };
95 
101 enum class ProxyTextureType
102 {
103  White,
104  Normal,
105 };
106 
107 class CommandList : public ::Effekseer::IReference
108 {
109 public:
110  CommandList() = default;
111  virtual ~CommandList() = default;
112 };
113 
114 class SingleFrameMemoryPool : public ::Effekseer::IReference
115 {
116 public:
117  SingleFrameMemoryPool() = default;
118  virtual ~SingleFrameMemoryPool() = default;
119 
125  virtual void NewFrame()
126  {
127  }
128 };
129 
130 struct DepthReconstructionParameter
131 {
132  float DepthBufferScale = 1.0f;
133  float DepthBufferOffset = 0.0f;
134  float ProjectionMatrix33 = 0.0f;
135  float ProjectionMatrix34 = 0.0f;
136  float ProjectionMatrix43 = 0.0f;
137  float ProjectionMatrix44 = 0.0f;
138 };
139 
140 ::Effekseer::ModelLoaderRef CreateModelLoader(::Effekseer::Backend::GraphicsDeviceRef gprahicsDevice, ::Effekseer::FileInterfaceRef fileInterface = nullptr);
141 
142 class Renderer : public ::Effekseer::IReference
143 {
144 protected:
145  Renderer();
146  virtual ~Renderer();
147 
148  class Impl;
149  std::unique_ptr<Impl> impl;
150 
151 public:
155  Impl* GetImpl();
156 
160  virtual void OnLostDevice() = 0;
161 
165  virtual void OnResetDevice() = 0;
166 
170  virtual void SetRestorationOfStatesFlag(bool flag) = 0;
171 
175  virtual bool BeginRendering() = 0;
176 
180  virtual bool EndRendering() = 0;
181 
185  virtual ::Effekseer::Vector3D GetLightDirection() const;
186 
190  virtual void SetLightDirection(const ::Effekseer::Vector3D& direction);
191 
195  virtual const ::Effekseer::Color& GetLightColor() const;
196 
200  virtual void SetLightColor(const ::Effekseer::Color& color);
201 
205  virtual const ::Effekseer::Color& GetLightAmbientColor() const;
206 
210  virtual void SetLightAmbientColor(const ::Effekseer::Color& color);
211 
215  virtual int32_t GetSquareMaxCount() const = 0;
216 
220  virtual ::Effekseer::Matrix44 GetProjectionMatrix() const;
221 
225  virtual void SetProjectionMatrix(const ::Effekseer::Matrix44& mat);
226 
230  virtual ::Effekseer::Matrix44 GetCameraMatrix() const;
231 
235  virtual void SetCameraMatrix(const ::Effekseer::Matrix44& mat);
236 
240  virtual ::Effekseer::Matrix44 GetCameraProjectionMatrix() const;
241 
247  virtual ::Effekseer::Vector3D GetCameraFrontDirection() const;
248 
254  virtual ::Effekseer::Vector3D GetCameraPosition() const;
255 
263  virtual void SetCameraParameter(const ::Effekseer::Vector3D& front, const ::Effekseer::Vector3D& position);
264 
268  virtual ::Effekseer::SpriteRendererRef CreateSpriteRenderer() = 0;
269 
273  virtual ::Effekseer::RibbonRendererRef CreateRibbonRenderer() = 0;
274 
278  virtual ::Effekseer::RingRendererRef CreateRingRenderer() = 0;
279 
283  virtual ::Effekseer::ModelRendererRef CreateModelRenderer() = 0;
284 
288  virtual ::Effekseer::TrackRendererRef CreateTrackRenderer() = 0;
289 
293  virtual ::Effekseer::TextureLoaderRef CreateTextureLoader(::Effekseer::FileInterfaceRef fileInterface = nullptr) = 0;
294 
298  virtual ::Effekseer::ModelLoaderRef CreateModelLoader(::Effekseer::FileInterfaceRef fileInterface = nullptr) = 0;
299 
306  virtual ::Effekseer::MaterialLoaderRef CreateMaterialLoader(::Effekseer::FileInterfaceRef fileInterface = nullptr) = 0;
307 
311  virtual void ResetRenderState() = 0;
312 
316  virtual DistortingCallback* GetDistortingCallback() = 0;
317 
321  virtual void SetDistortingCallback(DistortingCallback* callback) = 0;
322 
328  virtual int32_t GetDrawCallCount() const;
329 
335  virtual int32_t GetDrawVertexCount() const;
336 
342  virtual void ResetDrawCallCount();
343 
349  virtual void ResetDrawVertexCount();
350 
356  virtual Effekseer::RenderMode GetRenderMode() const;
357 
363  virtual void SetRenderMode(Effekseer::RenderMode renderMode);
364 
370  virtual UVStyle GetTextureUVStyle() const;
371 
377  virtual void SetTextureUVStyle(UVStyle style);
378 
384  virtual UVStyle GetBackgroundTextureUVStyle() const;
385 
391  virtual void SetBackgroundTextureUVStyle(UVStyle style);
392 
398  virtual float GetTime() const;
399 
405  virtual void SetTime(float time);
406 
412  virtual void SetCommandList(Effekseer::RefPtr<CommandList> commandList)
413  {
414  }
415 
423  virtual const ::Effekseer::Backend::TextureRef& GetBackground();
424 
430  virtual void SetBackground(::Effekseer::Backend::TextureRef texture);
431 
437  virtual ::Effekseer::Backend::TextureRef CreateProxyTexture(ProxyTextureType type);
438 
444  virtual void DeleteProxyTexture(Effekseer::Backend::TextureRef& texture);
445 
451  virtual void GetDepth(::Effekseer::Backend::TextureRef& texture, DepthReconstructionParameter& reconstructionParam);
452 
458  virtual void SetDepth(::Effekseer::Backend::TextureRef texture, const DepthReconstructionParameter& reconstructionParam);
459 
466  virtual void SetMaintainGammaColorInLinearColorSpace(bool value);
467 
473  virtual Effekseer::Backend::GraphicsDeviceRef GetGraphicsDevice() const;
474 
480  virtual std::shared_ptr<ExternalShaderSettings> GetExternalShaderSettings() const;
481 
487  virtual void SetExternalShaderSettings(const std::shared_ptr<ExternalShaderSettings>& settings);
488 };
489 
490 //----------------------------------------------------------------------------------
491 //
492 //----------------------------------------------------------------------------------
493 } // namespace EffekseerRenderer
494 //----------------------------------------------------------------------------------
495 //
496 //----------------------------------------------------------------------------------
497 #endif // __EFFEKSEERRENDERER_RENDERER_H__
498 #ifndef __EFFEKSEERRENDERER_TEXTURELOADER_H__
499 #define __EFFEKSEERRENDERER_TEXTURELOADER_H__
500 
501 #include <Effekseer.h>
502 
503 namespace EffekseerRenderer
504 {
505 
506 ::Effekseer::TextureLoaderRef CreateTextureLoader(::Effekseer::Backend::GraphicsDeviceRef gprahicsDevice,
507  ::Effekseer::FileInterfaceRef fileInterface = nullptr,
508  ::Effekseer::ColorSpaceType colorSpaceType = ::Effekseer::ColorSpaceType::Gamma);
509 
510 } // namespace EffekseerRenderer
511 
512 #endif // __EFFEKSEERRENDERER_TEXTURELOADER_H__
513 
514 #ifndef __EFFEKSEERRENDERER_DX12_RENDERER_H__
515 #define __EFFEKSEERRENDERER_DX12_RENDERER_H__
516 
517 #include <functional>
518 
519 namespace EffekseerRendererDX12
520 {
521 
522 ::Effekseer::Backend::GraphicsDeviceRef CreateGraphicsDevice(ID3D12Device* device, ID3D12CommandQueue* commandQueue, int32_t swapBufferCount);
523 
534 ::EffekseerRenderer::RendererRef Create(::Effekseer::Backend::GraphicsDeviceRef graphicsDevice,
535  DXGI_FORMAT* renderTargetFormats,
536  int32_t renderTargetCount,
537  DXGI_FORMAT depthFormat,
538  bool isReversedDepth,
539  int32_t squareMaxCount);
540 
553 ::EffekseerRenderer::RendererRef Create(ID3D12Device* device,
554  ID3D12CommandQueue* commandQueue,
555  int32_t swapBufferCount,
556  DXGI_FORMAT* renderTargetFormats,
557  int32_t renderTargetCount,
558  DXGI_FORMAT depthFormat,
559  bool isReversedDepth,
560  int32_t squareMaxCount);
561 
562 Effekseer::Backend::TextureRef CreateTexture(::Effekseer::Backend::GraphicsDeviceRef graphicsDevice, ID3D12Resource* texture);
563 
572 {
573  ID3D12Resource* TexturePtr = nullptr;
574 };
575 
576 TextureProperty GetTextureProperty(::Effekseer::Backend::TextureRef texture);
577 
586 {
587  ID3D12CommandList* CommandListPtr = nullptr;
588 };
589 
590 CommandListProperty GetCommandListProperty(Effekseer::RefPtr<EffekseerRenderer::CommandList> commandList);
591 
599 void BeginCommandList(Effekseer::RefPtr<EffekseerRenderer::CommandList> commandList, ID3D12GraphicsCommandList* dx12CommandList);
600 
601 void EndCommandList(Effekseer::RefPtr<EffekseerRenderer::CommandList> commandList);
602 
603 void ExecuteCommandList(Effekseer::RefPtr<EffekseerRenderer::CommandList> commandList);
604 
605 } // namespace EffekseerRendererDX12
606 
607 #endif
608 
609 #ifndef __EFFEKSEERRENDERER_LLGI_COMMON_H__
610 #define __EFFEKSEERRENDERER_LLGI_COMMON_H__
611 
612 #include <Effekseer.h>
613 
614 namespace EffekseerRenderer
615 {
616 
618 {
619  std::array<Effekseer::Backend::TextureFormatType, 8> RenderTargetFormats;
620  int32_t RenderTargetCount = 0;
621  Effekseer::Backend::TextureFormatType DepthFormat = Effekseer::Backend::TextureFormatType::Unknown;
622 };
623 
624 void ChangeRenderPassPipelineState(EffekseerRenderer::RendererRef renderer, RenderPassPipelineStateKey key);
625 
626 void FlushAndWait(::Effekseer::Backend::GraphicsDeviceRef graphicsDevice);
627 
628 Effekseer::RefPtr<EffekseerRenderer::CommandList> CreateCommandList(::Effekseer::Backend::GraphicsDeviceRef graphicsDevice,
629  Effekseer::RefPtr<::EffekseerRenderer::SingleFrameMemoryPool> memoryPool);
630 
631 Effekseer::RefPtr<EffekseerRenderer::SingleFrameMemoryPool> CreateSingleFrameMemoryPool(::Effekseer::Backend::GraphicsDeviceRef renderer);
632 
633 } // namespace EffekseerRenderer
634 
635 #endif
EffekseerRenderer::Renderer::GetDepth
virtual void GetDepth(::Effekseer::Backend::TextureRef &texture, DepthReconstructionParameter &reconstructionParam)
深度画像とZから深度を復元するためのパラメーターを取得する。
EffekseerRenderer::Renderer::SetExternalShaderSettings
virtual void SetExternalShaderSettings(const std::shared_ptr< ExternalShaderSettings > &settings)
Specify external shader settings
EffekseerRenderer::Renderer::SetCameraParameter
virtual void SetCameraParameter(const ::Effekseer::Vector3D &front, const ::Effekseer::Vector3D &position)
Set a front direction and position of camera manually
EffekseerRenderer::Renderer::GetRenderMode
virtual Effekseer::RenderMode GetRenderMode() const
描画モードを取得する。
EffekseerRenderer::Renderer::ResetDrawVertexCount
virtual void ResetDrawVertexCount()
描画された頂点数をリセットする
EffekseerRenderer::Renderer::GetDrawVertexCount
virtual int32_t GetDrawVertexCount() const
描画された頂点数をリセットする
EffekseerRenderer::Renderer::SetTime
virtual void SetTime(float time)
現在の時間を設定する。(秒)
EffekseerRenderer::DepthReconstructionParameter
Definition: EffekseerRendererDX9.h:151
EffekseerRenderer::Renderer::GetCameraMatrix
virtual ::Effekseer::Matrix44 GetCameraMatrix() const
Get a camera matrix
EffekseerRenderer::Renderer::GetDrawCallCount
virtual int32_t GetDrawCallCount() const
ドローコールの回数を取得する
EffekseerRenderer::Renderer::GetExternalShaderSettings
virtual std::shared_ptr< ExternalShaderSettings > GetExternalShaderSettings() const
Get external shader settings
EffekseerRenderer::Renderer::CreateTextureLoader
virtual ::Effekseer::TextureLoaderRef CreateTextureLoader(::Effekseer::FileInterfaceRef fileInterface=nullptr)=0
標準のテクスチャ読込クラスを生成する。
EffekseerRenderer::Renderer::SetMaintainGammaColorInLinearColorSpace
virtual void SetMaintainGammaColorInLinearColorSpace(bool value)
リニア空間でもガンマカラーを維持するようにするか、を設定する。
EffekseerRenderer::Renderer::GetBackgroundTextureUVStyle
virtual UVStyle GetBackgroundTextureUVStyle() const
パーティクルを描画するときの背景のUVの状態を取得する。
EffekseerRenderer::Renderer::ResetDrawCallCount
virtual void ResetDrawCallCount()
ドローコールの回数をリセットする
EffekseerRenderer::Renderer::GetCameraFrontDirection
virtual ::Effekseer::Vector3D GetCameraFrontDirection() const
Get a front direction of camera
EffekseerRenderer::Renderer::GetCameraProjectionMatrix
virtual ::Effekseer::Matrix44 GetCameraProjectionMatrix() const
Get a camera projection matrix
EffekseerRenderer::Renderer::SetLightColor
virtual void SetLightColor(const ::Effekseer::Color &color)
Specify the color of light
EffekseerRenderer::Renderer::SetCommandList
virtual void SetCommandList(Effekseer::RefPtr< CommandList > commandList)
描画に使用するコマンドリストを設定する。この関数はDirectX9、DirectX11、OpenGL以外で使用できる。
Definition: EffekseerRendererDX12.h:412
EffekseerRenderer::Renderer::CreateRibbonRenderer
virtual ::Effekseer::RibbonRendererRef CreateRibbonRenderer()=0
リボンレンダラーを生成する。
EffekseerRenderer::Renderer::SetLightAmbientColor
virtual void SetLightAmbientColor(const ::Effekseer::Color &color)
Specify the color of ambient
EffekseerRenderer::Renderer::GetImpl
Impl * GetImpl()
only for Effekseer backend developer. Effekseer User doesn't need it.
EffekseerRenderer::Renderer::SetTextureUVStyle
virtual void SetTextureUVStyle(UVStyle style)
パーティクルを描画するときのUVの状態を設定する。
EffekseerRenderer::Renderer::SetCameraMatrix
virtual void SetCameraMatrix(const ::Effekseer::Matrix44 &mat)
Set a camera matrix
EffekseerRenderer::Renderer::ResetRenderState
virtual void ResetRenderState()=0
レンダーステートを強制的にリセットする。
EffekseerRenderer::Renderer::SetRenderMode
virtual void SetRenderMode(Effekseer::RenderMode renderMode)
描画モードを設定する。
EffekseerRenderer::Renderer
Definition: EffekseerRendererDX9.h:163
EffekseerRenderer::Renderer::DeleteProxyTexture
virtual void DeleteProxyTexture(Effekseer::Backend::TextureRef &texture)
代替のテクスチャを削除する
EffekseerRenderer::Renderer::BeginRendering
virtual bool BeginRendering()=0
描画を開始する時に実行する。
EffekseerRenderer::Renderer::CreateSpriteRenderer
virtual ::Effekseer::SpriteRendererRef CreateSpriteRenderer()=0
スプライトレンダラーを生成する。
EffekseerRenderer::Renderer::SetProjectionMatrix
virtual void SetProjectionMatrix(const ::Effekseer::Matrix44 &mat)
Set a projection matrix
EffekseerRenderer::Renderer::GetTextureUVStyle
virtual UVStyle GetTextureUVStyle() const
パーティクルを描画するときのUVの状態を取得する。
EffekseerRenderer::Renderer::GetProjectionMatrix
virtual ::Effekseer::Matrix44 GetProjectionMatrix() const
Get a projection matrix
EffekseerRenderer::Renderer::SetBackground
virtual void SetBackground(::Effekseer::Backend::TextureRef texture)
背景のテクスチャを設定する。
EffekseerRenderer::Renderer::EndRendering
virtual bool EndRendering()=0
描画を終了する時に実行する。
EffekseerRenderer::Renderer::SetLightDirection
virtual void SetLightDirection(const ::Effekseer::Vector3D &direction)
Specifiy the direction of light
EffekseerRenderer::Renderer::CreateRingRenderer
virtual ::Effekseer::RingRendererRef CreateRingRenderer()=0
リングレンダラーを生成する。
EffekseerRendererDX12::CommandListProperty
コマンドリスト内のプロパティ
Definition: EffekseerRendererDX12.h:585
EffekseerRenderer::Renderer::SetDepth
virtual void SetDepth(::Effekseer::Backend::TextureRef texture, const DepthReconstructionParameter &reconstructionParam)
深度画像とZから深度を復元するためのパラメーターを設定する。
EffekseerRendererDX12::TextureProperty
テクスチャ内のプロパティ
Definition: EffekseerRendererDX12.h:571
EffekseerRenderer::Renderer::CreateTrackRenderer
virtual ::Effekseer::TrackRendererRef CreateTrackRenderer()=0
軌跡レンダラーを生成する。
EffekseerRenderer::Renderer::SetRestorationOfStatesFlag
virtual void SetRestorationOfStatesFlag(bool flag)=0
ステートを復帰するかどうかのフラグを設定する。
EffekseerRenderer::Renderer::OnLostDevice
virtual void OnLostDevice()=0
デバイスロストが発生した時に実行する。
EffekseerRenderer::Renderer::OnResetDevice
virtual void OnResetDevice()=0
デバイスがリセットされた時に実行する。
EffekseerRenderer::Renderer::GetBackground
virtual const ::Effekseer::Backend::TextureRef & GetBackground()
背景を取得する。
EffekseerRenderer::Renderer::GetLightColor
virtual const ::Effekseer::Color & GetLightColor() const
Get the color of light
EffekseerRenderer::SingleFrameMemoryPool::NewFrame
virtual void NewFrame()
新規フレームが始ったことを通知する。
Definition: EffekseerRendererDX12.h:125
EffekseerRenderer::Renderer::CreateMaterialLoader
virtual ::Effekseer::MaterialLoaderRef CreateMaterialLoader(::Effekseer::FileInterfaceRef fileInterface=nullptr)=0
標準のマテリアル読込クラスを生成する。
EffekseerRenderer::Renderer::GetLightDirection
virtual ::Effekseer::Vector3D GetLightDirection() const
Get the direction of light
EffekseerRenderer::Renderer::CreateProxyTexture
virtual ::Effekseer::Backend::TextureRef CreateProxyTexture(ProxyTextureType type)
代替のテクスチャを生成する
EffekseerRenderer::DistortingCallback::OnDistorting
virtual bool OnDistorting(Renderer *renderer)
コールバック
Definition: EffekseerRendererDX12.h:79
EffekseerRenderer::RenderPassPipelineStateKey
Definition: EffekseerRendererDX12.h:617
EffekseerRenderer::Renderer::SetBackgroundTextureUVStyle
virtual void SetBackgroundTextureUVStyle(UVStyle style)
パーティクルを描画するときの背景のUVの状態を設定する。
EffekseerRenderer::Renderer::SetDistortingCallback
virtual void SetDistortingCallback(DistortingCallback *callback)=0
背景を歪ませるエフェクトが描画される前に呼ばれるコールバックを設定する。
EffekseerRenderer::Renderer::CreateModelLoader
virtual ::Effekseer::ModelLoaderRef CreateModelLoader(::Effekseer::FileInterfaceRef fileInterface=nullptr)=0
標準のモデル読込クラスを生成する。
EffekseerRenderer::Renderer::GetCameraPosition
virtual ::Effekseer::Vector3D GetCameraPosition() const
Get a position of camera
EffekseerRenderer::Renderer::GetGraphicsDevice
virtual Effekseer::Backend::GraphicsDeviceRef GetGraphicsDevice() const
グラフィクスデバイスを取得する。
EffekseerRenderer::Renderer::CreateModelRenderer
virtual ::Effekseer::ModelRendererRef CreateModelRenderer()=0
モデルレンダラーを生成する。
EffekseerRenderer::Renderer::GetLightAmbientColor
virtual const ::Effekseer::Color & GetLightAmbientColor() const
Get the color of ambient
EffekseerRenderer::Renderer::GetDistortingCallback
virtual DistortingCallback * GetDistortingCallback()=0
背景を歪ませるエフェクトが描画される前に呼ばれるコールバックを取得する。
EffekseerRenderer::Renderer::GetSquareMaxCount
virtual int32_t GetSquareMaxCount() const =0
最大描画スプライト数を取得する。
EffekseerRenderer::Renderer::GetTime
virtual float GetTime() const
現在の時間を取得する。(秒)