Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ set(LIBRARY_SOURCES
Src/DebugEffect.cpp
Src/DGSLEffect.cpp
Src/NPREffect.cpp
Src/NPREffectFactory.cpp
Src/DGSLEffectFactory.cpp
Src/DirectXHelpers.cpp
Src/DualPostProcess.cpp
Expand Down Expand Up @@ -296,7 +297,9 @@ if(WIN32 AND BUILD_SHARED_LIBS)
target_compile_definitions(${PROJECT_NAME} INTERFACE DIRECTX_TOOLKIT_IMPORT)

if(XBOX_CONSOLE_TARGET MATCHES "durango")
target_link_libraries(${PROJECT_NAME} PRIVATE kernelx.lib combase.lib d3d12_x.lib xi.lib)
target_link_libraries(${PROJECT_NAME} PRIVATE kernelx.lib combase.lib d3d11_x.lib xi.lib)
else()
target_link_libraries(${PROJECT_NAME} PRIVATE d3d11.lib dxguid.lib)
endif()

if(MINGW AND BUILD_XINPUT)
Expand Down
1 change: 1 addition & 0 deletions DirectXTK_Desktop_2022.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
<ClCompile Include="Src\ModelLoadVBO.cpp" />
<ClCompile Include="Src\Mouse.cpp" />
<ClCompile Include="Src\NormalMapEffect.cpp" />
<ClCompile Include="Src\NPREffectFactory.cpp" />
<ClCompile Include="Src\PBREffect.cpp" />
<ClCompile Include="Src\PBREffectFactory.cpp" />
<ClCompile Include="Src\pch.cpp">
Expand Down
3 changes: 3 additions & 0 deletions DirectXTK_Desktop_2022.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@
<ClCompile Include="Audio\WAVFileReader.cpp">
<Filter>Audio</Filter>
</ClCompile>
<ClCompile Include="Src\NPREffectFactory.cpp">
<Filter>Src</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="Src\Shaders\CompileShaders.cmd">
Expand Down
1 change: 1 addition & 0 deletions DirectXTK_Desktop_2022_Win10.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
<ClCompile Include="Src\ModelLoadVBO.cpp" />
<ClCompile Include="Src\Mouse.cpp" />
<ClCompile Include="Src\NormalMapEffect.cpp" />
<ClCompile Include="Src\NPREffectFactory.cpp" />
<ClCompile Include="Src\PBREffect.cpp" />
<ClCompile Include="Src\PBREffectFactory.cpp" />
<ClCompile Include="Src\pch.cpp">
Expand Down
3 changes: 3 additions & 0 deletions DirectXTK_Desktop_2022_Win10.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@
<ClCompile Include="Src\DirectXHelpers.cpp">
<Filter>Src</Filter>
</ClCompile>
<ClCompile Include="Src\NPREffectFactory.cpp">
<Filter>Src</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="Src\Shaders\CompileShaders.cmd">
Expand Down
6 changes: 3 additions & 3 deletions DirectXTK_Desktop_2026.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<Folder Name="/Solution Items/">
<File Path=".editorconfig" />
</Folder>
<Project Path="DirectXTK_Desktop_2026.vcxproj">
<Project Path="DirectXTK_Desktop_2026.vcxproj" Id="e0b52ae7-e160-4d32-bf3f-910b785e5a8e">
<Platform Solution="*|Mixed Platforms" Project="Win32" />
</Project>
<Project Path="MakeSpriteFont/MakeSpriteFont.csproj" />
<Project Path="XWBTool/XWBTool_Desktop_2026.vcxproj">
<Project Path="MakeSpriteFont/MakeSpriteFont.csproj" Id="7329b02d-c504-482a-a156-181d48ce493c" />
<Project Path="XWBTool/XWBTool_Desktop_2026.vcxproj" Id="c7ab4186-54b2-4244-a533-77494763ea1d">
<Platform Solution="*|Mixed Platforms" Project="Win32" />
</Project>
</Solution>
1 change: 1 addition & 0 deletions DirectXTK_Desktop_2026.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
<ClCompile Include="Src\ModelLoadVBO.cpp" />
<ClCompile Include="Src\Mouse.cpp" />
<ClCompile Include="Src\NormalMapEffect.cpp" />
<ClCompile Include="Src\NPREffectFactory.cpp" />
<ClCompile Include="Src\PBREffect.cpp" />
<ClCompile Include="Src\PBREffectFactory.cpp" />
<ClCompile Include="Src\pch.cpp">
Expand Down
3 changes: 3 additions & 0 deletions DirectXTK_Desktop_2026.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@
<ClCompile Include="Src\DirectXHelpers.cpp">
<Filter>Src</Filter>
</ClCompile>
<ClCompile Include="Src\NPREffectFactory.cpp">
<Filter>Src</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="Src\Shaders\CompileShaders.cmd">
Expand Down
1 change: 1 addition & 0 deletions DirectXTK_GDKW_2022.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@
<ClCompile Include="Src\ModelLoadVBO.cpp" />
<ClCompile Include="Src\Mouse.cpp" />
<ClCompile Include="Src\NormalMapEffect.cpp" />
<ClCompile Include="Src\NPREffectFactory.cpp" />
<ClCompile Include="Src\PBREffect.cpp" />
<ClCompile Include="Src\PBREffectFactory.cpp" />
<ClCompile Include="Src\pch.cpp">
Expand Down
3 changes: 3 additions & 0 deletions DirectXTK_GDKW_2022.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@
<ClCompile Include="Audio\SoundStreamInstance.cpp">
<Filter>Audio</Filter>
</ClCompile>
<ClCompile Include="Src\NPREffectFactory.cpp">
<Filter>Src</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="Src\Shaders\CompileShaders.cmd">
Expand Down
1 change: 1 addition & 0 deletions DirectXTK_GDK_2022.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@
<ClCompile Include="Src\ModelLoadVBO.cpp" />
<ClCompile Include="Src\Mouse.cpp" />
<ClCompile Include="Src\NormalMapEffect.cpp" />
<ClCompile Include="Src\NPREffectFactory.cpp" />
<ClCompile Include="Src\PBREffect.cpp" />
<ClCompile Include="Src\PBREffectFactory.cpp" />
<ClCompile Include="Src\pch.cpp">
Expand Down
3 changes: 3 additions & 0 deletions DirectXTK_GDK_2022.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@
<ClCompile Include="Audio\SoundStreamInstance.cpp">
<Filter>Audio</Filter>
</ClCompile>
<ClCompile Include="Src\NPREffectFactory.cpp">
<Filter>Src</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="Src\Shaders\CompileShaders.cmd">
Expand Down
1 change: 1 addition & 0 deletions DirectXTK_Windows10_2022.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
<ClCompile Include="Src\ModelLoadVBO.cpp" />
<ClCompile Include="Src\Mouse.cpp" />
<ClCompile Include="Src\NormalMapEffect.cpp" />
<ClCompile Include="Src\NPREffectFactory.cpp" />
<ClCompile Include="Src\PBREffect.cpp" />
<ClCompile Include="Src\PBREffectFactory.cpp" />
<ClCompile Include="Src\pch.cpp">
Expand Down
3 changes: 3 additions & 0 deletions DirectXTK_Windows10_2022.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -365,5 +365,8 @@
<ClCompile Include="Src\DirectXHelpers.cpp">
<Filter>Src</Filter>
</ClCompile>
<ClCompile Include="Src\NPREffectFactory.cpp">
<Filter>Src</Filter>
</ClCompile>
</ItemGroup>
</Project>
92 changes: 85 additions & 7 deletions Inc/Effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -578,13 +578,14 @@ namespace DirectX
static constexpr int MaxTextures = 8;

protected:
// Private implementation.
// Internal implementation.
class Impl;

std::unique_ptr<Impl> pImpl;

DIRECTX_TOOLKIT_API DGSLEffect(_In_ ID3D11Device* device, _In_opt_ ID3D11PixelShader* pixelShader, bool skinningEnabled);

private:
// Unsupported interface methods.
DIRECTX_TOOLKIT_API void __cdecl SetPerPixelLighting(bool value) override;
};
Expand All @@ -604,7 +605,7 @@ namespace DirectX

~SkinnedDGSLEffect() override;

// Animation setting.
// Animation settings.
void __cdecl SetWeightsPerVertex(int value) override;
void __cdecl SetBoneTransforms(_In_reads_(count) XMMATRIX const* value, size_t count) override;
void __cdecl ResetBoneTransforms() override;
Expand Down Expand Up @@ -680,13 +681,14 @@ namespace DirectX
DIRECTX_TOOLKIT_API void __cdecl SetInstancingEnabled(bool value);

protected:
// Private implementation.
// Internal implementation.
class Impl;

std::unique_ptr<Impl> pImpl;

DIRECTX_TOOLKIT_API NormalMapEffect(_In_ ID3D11Device* device, bool skinningEnabled);

private:
// Unsupported interface methods.
DIRECTX_TOOLKIT_API void __cdecl SetLightingEnabled(bool value) override;
DIRECTX_TOOLKIT_API void __cdecl SetPerPixelLighting(bool value) override;
Expand Down Expand Up @@ -786,13 +788,14 @@ namespace DirectX
DIRECTX_TOOLKIT_API void __cdecl SetRenderTargetSizeInPixels(int width, int height);

protected:
// Private implementation.
// Internal implementation.
class Impl;

std::unique_ptr<Impl> pImpl;

DIRECTX_TOOLKIT_API PBREffect(_In_ ID3D11Device* device, bool skinningEnabled);

private:
// Unsupported interface methods.
DIRECTX_TOOLKIT_API void __cdecl SetLightingEnabled(bool value) override;
DIRECTX_TOOLKIT_API void __cdecl SetPerPixelLighting(bool value) override;
Expand Down Expand Up @@ -890,7 +893,9 @@ namespace DirectX
Mode_MatCap, // Material Capture shading
};

DIRECTX_TOOLKIT_API explicit NPREffect(_In_ ID3D11Device* device);
DIRECTX_TOOLKIT_API inline explicit NPREffect(_In_ ID3D11Device* device) :
NPREffect(device, false)
{}

DIRECTX_TOOLKIT_API NPREffect(NPREffect&&) noexcept;
DIRECTX_TOOLKIT_API NPREffect& operator= (NPREffect&&) noexcept;
Expand Down Expand Up @@ -960,12 +965,15 @@ namespace DirectX
// Instancing settings.
DIRECTX_TOOLKIT_API void __cdecl SetInstancingEnabled(bool value);

private:
// Private implementation.
protected:
// Internal implementation.
class Impl;

std::unique_ptr<Impl> pImpl;

DIRECTX_TOOLKIT_API NPREffect(_In_ ID3D11Device* device, bool skinningEnabled);

private:
// Unsupported interface methods.
DIRECTX_TOOLKIT_API void __cdecl SetLightingEnabled(bool value) override;
DIRECTX_TOOLKIT_API void __cdecl SetPerPixelLighting(bool value) override;
Expand All @@ -975,6 +983,27 @@ namespace DirectX
DIRECTX_TOOLKIT_API void XM_CALLCONV SetLightSpecularColor(int whichLight, FXMVECTOR value) override;
};

class DIRECTX_TOOLKIT_API SkinnedNPREffect : public NPREffect, public IEffectSkinning
{
public:
explicit SkinnedNPREffect(_In_ ID3D11Device* device) :
NPREffect(device, true)
{}

SkinnedNPREffect(SkinnedNPREffect&&) = default;
SkinnedNPREffect& operator= (SkinnedNPREffect&&) = default;

SkinnedNPREffect(SkinnedNPREffect const&) = delete;
SkinnedNPREffect& operator= (SkinnedNPREffect const&) = delete;

~SkinnedNPREffect() override;

// Animation settings.
void __cdecl SetWeightsPerVertex(int value) override;
void __cdecl SetBoneTransforms(_In_reads_(count) XMMATRIX const* value, size_t count) override;
void __cdecl ResetBoneTransforms() override;
};

//------------------------------------------------------------------------------
// Abstract interface to factory for sharing effects and texture resources
class DIRECTX_TOOLKIT_API IEffectFactory
Expand Down Expand Up @@ -1127,6 +1156,55 @@ namespace DirectX
};


// Factory for Non-Photorealistic Rendering (NPR)
class NPREffectFactory : public IEffectFactory
{
public:
DIRECTX_TOOLKIT_API explicit NPREffectFactory(_In_ ID3D11Device* device);

DIRECTX_TOOLKIT_API NPREffectFactory(NPREffectFactory&&) noexcept;
DIRECTX_TOOLKIT_API NPREffectFactory& operator= (NPREffectFactory&&) noexcept;

NPREffectFactory(NPREffectFactory const&) = delete;
NPREffectFactory& operator= (NPREffectFactory const&) = delete;

DIRECTX_TOOLKIT_API ~NPREffectFactory() override;

// IEffectFactory methods.
DIRECTX_TOOLKIT_API std::shared_ptr<IEffect> __cdecl CreateEffect(
_In_ const EffectInfo& info,
_In_opt_ ID3D11DeviceContext* deviceContext) override;
DIRECTX_TOOLKIT_API void __cdecl CreateTexture(
_In_z_ const wchar_t* name,
_In_opt_ ID3D11DeviceContext* deviceContext,
_Outptr_ ID3D11ShaderResourceView** textureView) override;

// Settings.
DIRECTX_TOOLKIT_API void __cdecl ReleaseCache();

DIRECTX_TOOLKIT_API void __cdecl SetSharing(bool enabled) noexcept;

DIRECTX_TOOLKIT_API void __cdecl EnableForceSRGB(bool forceSRGB) noexcept;

DIRECTX_TOOLKIT_API void __cdecl SetDirectory(_In_opt_z_ const wchar_t* path) noexcept;

DIRECTX_TOOLKIT_API void __cdecl SetMode(NPREffect::Mode mode) noexcept;

DIRECTX_TOOLKIT_API void __cdecl SetDefaultMatCap(_In_opt_ ID3D11ShaderResourceView* textureView) noexcept;

DIRECTX_TOOLKIT_API void __cdecl SetEmissiveAsMatCap(bool value) noexcept;

// Properties.
DIRECTX_TOOLKIT_API ID3D11Device* GetDevice() const noexcept;

private:
// Private implementation.
class Impl;

std::shared_ptr<Impl> pImpl;
};


// Factory for sharing Visual Studio Shader Designer (DGSL) shaders and texture resources
class DGSLEffectFactory : public IEffectFactory
{
Expand Down
12 changes: 5 additions & 7 deletions Src/DGSLEffectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@ class DGSLEffectFactory::Impl
void CreatePixelShader(_In_z_ const wchar_t* shader, _Outptr_ ID3D11PixelShader** pixelShader);

void ReleaseCache();
void SetSharing(bool enabled) noexcept { mSharing = enabled; }
void EnableForceSRGB(bool forceSRGB) noexcept { mForceSRGB = forceSRGB; }

static SharedResourcePool<ID3D11Device*, Impl> instancePool;

wchar_t mPath[MAX_PATH];

ComPtr<ID3D11Device> mDevice;

bool mSharing;
bool mForceSRGB;

private:
using EffectCache = std::map< std::wstring, std::shared_ptr<IEffect> >;
using TextureCache = std::map< std::wstring, ComPtr<ID3D11ShaderResourceView> >;
Expand All @@ -70,9 +71,6 @@ class DGSLEffectFactory::Impl
TextureCache mTextureCache;
ShaderCache mShaderCache;

bool mSharing;
bool mForceSRGB;

std::mutex mutex;
};

Expand Down Expand Up @@ -590,12 +588,12 @@ void DGSLEffectFactory::ReleaseCache()

void DGSLEffectFactory::SetSharing(bool enabled) noexcept
{
pImpl->SetSharing(enabled);
pImpl->mSharing = enabled;
}

void DGSLEffectFactory::EnableForceSRGB(bool forceSRGB) noexcept
{
pImpl->EnableForceSRGB(forceSRGB);
pImpl->mForceSRGB = forceSRGB;
}

void DGSLEffectFactory::SetDirectory(_In_opt_z_ const wchar_t* path) noexcept
Expand Down
Loading
Loading