mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Melhoria em uso de Effect em SpriteBatch.Begin
This commit is contained in:
parent
0ce4255e10
commit
1c432de78f
@ -22,6 +22,7 @@ project ("xna")
|
|||||||
# Include sub-projects.
|
# Include sub-projects.
|
||||||
include_directories(${PROJECT_INCLUDES_DIR})
|
include_directories(${PROJECT_INCLUDES_DIR})
|
||||||
add_subdirectory ("framework")
|
add_subdirectory ("framework")
|
||||||
add_subdirectory ("samples")
|
|
||||||
|
#add_subdirectory ("samples")
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ namespace xna {
|
|||||||
_description.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
_description.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
||||||
_description.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
|
_description.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
|
||||||
|
|
||||||
_description.StencilReadMask = IntMaxValue;
|
_description.StencilReadMask = static_cast<UINT8>(IntMaxValue);
|
||||||
_description.StencilWriteMask = IntMaxValue;
|
_description.StencilWriteMask = static_cast<UINT8>(IntMaxValue);
|
||||||
_description.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
_description.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
||||||
|
|
||||||
return _description;
|
return _description;
|
||||||
|
@ -150,27 +150,38 @@ namespace xna {
|
|||||||
t.M21, t.M22, t.M23, t.M24,
|
t.M21, t.M22, t.M23, t.M24,
|
||||||
t.M31, t.M32, t.M33, t.M34,
|
t.M31, t.M32, t.M33, t.M34,
|
||||||
t.M41, t.M42, t.M43, t.M44);
|
t.M41, t.M42, t.M43, t.M44);
|
||||||
|
|
||||||
|
std::function<void __cdecl()> effectFunc = nullptr;
|
||||||
|
|
||||||
if (effect && !impl->dxInputLayout) {
|
//if Effect is not null set effectBuffer and inputLayout
|
||||||
void const* shaderByteCode;
|
if (effect && effect->impl) {
|
||||||
size_t byteCodeLength;
|
bool effectBufferChanged = false;
|
||||||
|
|
||||||
effect->impl->dxEffect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength);
|
if (!impl->effectBuffer || impl->effectBuffer != effect->impl->dxEffect) {
|
||||||
|
impl->effectBuffer = effect->impl->dxEffect;
|
||||||
|
effectBufferChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
m_device->impl->_device->CreateInputLayout(
|
if (effectBufferChanged) {
|
||||||
DirectX::VertexPositionColorTexture::InputElements,
|
void const* shaderByteCode;
|
||||||
DirectX::VertexPositionColorTexture::InputElementCount,
|
size_t byteCodeLength;
|
||||||
shaderByteCode, byteCodeLength,
|
|
||||||
impl->dxInputLayout.GetAddressOf());
|
|
||||||
}
|
|
||||||
|
|
||||||
auto& context = m_device->impl->_context;
|
effect->impl->dxEffect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength);
|
||||||
|
|
||||||
std::function funcEffect = [=] {
|
m_device->impl->_device->CreateInputLayout(
|
||||||
effect->impl->dxEffect->Apply(context.Get());
|
DirectX::VertexPositionColorTexture::InputElements,
|
||||||
context->IASetInputLayout(impl->dxInputLayout.Get());
|
DirectX::VertexPositionColorTexture::InputElementCount,
|
||||||
};
|
shaderByteCode, byteCodeLength,
|
||||||
std::function funcVoid = [=] {};
|
impl->dxInputLayout.GetAddressOf());
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& context = m_device->impl->_context;
|
||||||
|
|
||||||
|
effectFunc = [=] {
|
||||||
|
impl->effectBuffer->Apply(context.Get());
|
||||||
|
context->IASetInputLayout(impl->dxInputLayout.Get());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
impl->_dxspriteBatch->Begin(
|
impl->_dxspriteBatch->Begin(
|
||||||
sort,
|
sort,
|
||||||
@ -178,7 +189,7 @@ namespace xna {
|
|||||||
samplerState ? samplerState->impl->_samplerState.Get() : nullptr,
|
samplerState ? samplerState->impl->_samplerState.Get() : nullptr,
|
||||||
depthStencil ? depthStencil->impl->dxDepthStencil.Get() : nullptr,
|
depthStencil ? depthStencil->impl->dxDepthStencil.Get() : nullptr,
|
||||||
rasterizerState ? rasterizerState->impl->dxRasterizerState.Get() : nullptr,
|
rasterizerState ? rasterizerState->impl->dxRasterizerState.Get() : nullptr,
|
||||||
effect ? funcEffect : funcVoid,
|
effectFunc,
|
||||||
matrix
|
matrix
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#ifndef XNA_PLATFORMDX_DX_HPP
|
#ifndef XNA_XNA_DX_HPP
|
||||||
#define XNA_PLATFORMDX_DX_HPP
|
#define XNA_XNA_DX_HPP
|
||||||
|
|
||||||
|
#define NOMINMAX
|
||||||
|
|
||||||
//---------------- DX INCLUDES ----------------//
|
//---------------- DX INCLUDES ----------------//
|
||||||
|
|
||||||
@ -12,10 +14,12 @@
|
|||||||
#include "d3d11.h"
|
#include "d3d11.h"
|
||||||
#include <d3d11_1.h>
|
#include <d3d11_1.h>
|
||||||
#include <d3d11_2.h>
|
#include <d3d11_2.h>
|
||||||
//HSLS AND EFFECTS
|
#include <d3d11_3.h>
|
||||||
#include <d3dcompiler.h>
|
#include <d3d11_4.h>
|
||||||
#include <d3d11shader.h>
|
#include <d3d11shader.h>
|
||||||
#include "effects11/d3dx11effect.h"
|
#include <d3d11shadertracing.h>
|
||||||
|
#include <d3dcommon.h>
|
||||||
|
#include <d3dcsx.h>
|
||||||
//DirectXTK
|
//DirectXTK
|
||||||
#include <DirectXMath.h>
|
#include <DirectXMath.h>
|
||||||
#include <Audio.h>
|
#include <Audio.h>
|
||||||
@ -39,7 +43,6 @@
|
|||||||
#include <VertexTypes.h>
|
#include <VertexTypes.h>
|
||||||
#include <WICTextureLoader.h>
|
#include <WICTextureLoader.h>
|
||||||
//Windows
|
//Windows
|
||||||
#define NOMINMAX
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
#include <Windows.Foundation.h>
|
#include <Windows.Foundation.h>
|
||||||
@ -62,7 +65,7 @@ namespace xna {
|
|||||||
|
|
||||||
struct DxHelpers {
|
struct DxHelpers {
|
||||||
static constexpr DirectX::XMVECTOR VectorToDx(Vector2 const& value) {
|
static constexpr DirectX::XMVECTOR VectorToDx(Vector2 const& value) {
|
||||||
DirectX::XMVECTOR v;
|
DirectX::XMVECTOR v{};
|
||||||
|
|
||||||
v.m128_f32[0] = value.X;
|
v.m128_f32[0] = value.X;
|
||||||
v.m128_f32[1] = value.Y;
|
v.m128_f32[1] = value.Y;
|
||||||
@ -72,7 +75,7 @@ namespace xna {
|
|||||||
|
|
||||||
|
|
||||||
static constexpr DirectX::XMVECTOR VectorToDx(Vector3 const& value) {
|
static constexpr DirectX::XMVECTOR VectorToDx(Vector3 const& value) {
|
||||||
DirectX::XMVECTOR v;
|
DirectX::XMVECTOR v{};
|
||||||
|
|
||||||
v.m128_f32[0] = value.X;
|
v.m128_f32[0] = value.X;
|
||||||
v.m128_f32[1] = value.Y;
|
v.m128_f32[1] = value.Y;
|
||||||
@ -82,7 +85,7 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static constexpr DirectX::XMFLOAT3 Vector3ToDx(Vector3 const& value) {
|
static constexpr DirectX::XMFLOAT3 Vector3ToDx(Vector3 const& value) {
|
||||||
DirectX::XMFLOAT3 v;
|
DirectX::XMFLOAT3 v{};
|
||||||
|
|
||||||
v.x = value.X;
|
v.x = value.X;
|
||||||
v.y = value.Y;
|
v.y = value.Y;
|
||||||
@ -92,7 +95,7 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static constexpr DirectX::XMVECTOR VectorToDx(Vector4 const& value) {
|
static constexpr DirectX::XMVECTOR VectorToDx(Vector4 const& value) {
|
||||||
DirectX::XMVECTOR v;
|
DirectX::XMVECTOR v{};
|
||||||
|
|
||||||
v.m128_f32[0] = value.X;
|
v.m128_f32[0] = value.X;
|
||||||
v.m128_f32[1] = value.Y;
|
v.m128_f32[1] = value.Y;
|
||||||
@ -554,7 +557,7 @@ namespace xna {
|
|||||||
uint64_t m_targetElapsedTicks;
|
uint64_t m_targetElapsedTicks;
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------- IMPL ----------------//
|
//---------------- IMPLEMENTATIONS ----------------//
|
||||||
|
|
||||||
struct SpriteFont::PlatformImplementation {
|
struct SpriteFont::PlatformImplementation {
|
||||||
uptr<DirectX::SpriteFont> _dxSpriteFont{ nullptr };
|
uptr<DirectX::SpriteFont> _dxSpriteFont{ nullptr };
|
||||||
@ -563,6 +566,7 @@ namespace xna {
|
|||||||
struct SpriteBatch::PlatformImplementation {
|
struct SpriteBatch::PlatformImplementation {
|
||||||
sptr<DirectX::SpriteBatch> _dxspriteBatch = nullptr;
|
sptr<DirectX::SpriteBatch> _dxspriteBatch = nullptr;
|
||||||
comptr<ID3D11InputLayout> dxInputLayout = nullptr;
|
comptr<ID3D11InputLayout> dxInputLayout = nullptr;
|
||||||
|
sptr<DirectX::DX11::IEffect> effectBuffer = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GraphicsAdapter::PlatformImplementation {
|
struct GraphicsAdapter::PlatformImplementation {
|
||||||
@ -683,7 +687,7 @@ namespace xna {
|
|||||||
DXGI_SWAP_CHAIN_DESC1 dxDescription{};
|
DXGI_SWAP_CHAIN_DESC1 dxDescription{};
|
||||||
DXGI_SWAP_CHAIN_FULLSCREEN_DESC dxFullScreenDescription{};
|
DXGI_SWAP_CHAIN_FULLSCREEN_DESC dxFullScreenDescription{};
|
||||||
|
|
||||||
bool GetBackBuffer(comptr<ID3D11Texture2D>& texture2D) {
|
bool GetBackBuffer(comptr<ID3D11Texture2D>& texture2D) const {
|
||||||
if (!dxSwapChain)
|
if (!dxSwapChain)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -769,7 +773,7 @@ namespace xna {
|
|||||||
ShowCursor(visible);
|
ShowCursor(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Close() {
|
inline void Close() const {
|
||||||
PostMessage(_windowHandle, WM_DESTROY, 0, 0);
|
PostMessage(_windowHandle, WM_DESTROY, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,2 +1 @@
|
|||||||
#include "xna/xna.hpp"
|
|
||||||
#include "xna/xna-dx.hpp"
|
#include "xna/xna-dx.hpp"
|
Loading…
x
Reference in New Issue
Block a user