├── Project ├── Template │ ├── Common.h │ ├── DXSample.cpp │ ├── Win32Application.h │ ├── DXSample.h │ └── Win32Application.cpp ├── Part03_Texture │ ├── Main.cpp │ ├── Scene.cpp │ ├── image.png │ ├── Shader │ │ ├── ClearScreenWithSampler.hlsl │ │ └── ClearScreenWithTexture.hlsl │ ├── Part03_Texture.vcxproj.filters │ └── Scene.h ├── Part06_DrawCall │ ├── Scene.h │ ├── Main.cpp │ ├── Scene.cpp │ ├── Shader │ │ ├── VertexShaderWithSlot.hlsl │ │ ├── PixelShader.hlsl │ │ ├── VertexShader.hlsl │ │ └── VertexShaderWithStructuredBuffer.hlsl │ └── Part06_DrawCall.vcxproj.filters ├── Part14_Query │ ├── Main.cpp │ ├── Scene.cpp │ ├── Shader │ │ ├── VSStreamOutput.hlsl │ │ ├── PixelShader.hlsl │ │ ├── VertexShader.hlsl │ │ └── GeometryShader.hlsl │ ├── Part14_Query.vcxproj.filters │ └── Scene.h ├── Part16_Texture2 │ ├── Main.cpp │ ├── Scene.cpp │ ├── Shader │ │ ├── CSArrayRead.hlsl │ │ ├── CSArrayWrite.hlsl │ │ ├── CSMipmapRead.hlsl │ │ ├── CSUseCubemap.hlsl │ │ ├── CSMipmapWrite.hlsl │ │ ├── GSRenderCubemap.hlsl │ │ ├── VSDummy.hlsl │ │ ├── PSRenderCubemap.hlsl │ │ ├── PSRenderMultisampling.hlsl │ │ ├── ClearScreenWithSampler.hlsl │ │ ├── Common.hlsli │ │ └── GSRenderMultisampling.hlsl │ ├── Part16_Texture2.vcxproj.filters │ └── Scene.h ├── Part01_ClearScreen │ ├── Main.cpp │ ├── Scene.cpp │ ├── Shader │ │ └── ClearScreen.hlsl │ ├── Scene.h │ └── Part01_ClearScreen.vcxproj.filters ├── Part04_TypeOfBuffer │ ├── Main.cpp │ ├── Scene.cpp │ ├── Shader │ │ ├── RenderSphereByConstantBuffer.hlsl │ │ ├── RenderSphereByByteAddressBuffer.hlsl │ │ ├── RenderSphereByStructuredBuffer.hlsl │ │ ├── PopStack.hlsl │ │ ├── PushStack.hlsl │ │ └── Common.hlsli │ ├── Scene.h │ └── Part04_TypeOfBuffer.vcxproj.filters ├── Part11_StreamOutput │ ├── Main.cpp │ ├── Scene.cpp │ ├── Shader │ │ ├── VSStreamOutput.hlsl │ │ ├── PixelShader.hlsl │ │ ├── VertexShader.hlsl │ │ └── GeometryShader.hlsl │ ├── Scene.h │ └── Part11_StreamOutput.vcxproj.filters ├── Part12_Tessellation │ ├── Main.cpp │ ├── Scene.cpp │ ├── Shader │ │ ├── DSQuad.hlsl │ │ ├── HSQuad.hlsl │ │ ├── DSIsoline.hlsl │ │ ├── DSTriangle.hlsl │ │ ├── HSIsoline.hlsl │ │ ├── HSTriangle.hlsl │ │ ├── DSPointToTriangle.hlsl │ │ ├── HSPointToTriangle.hlsl │ │ ├── VS.hlsl │ │ └── PixelShader.hlsl │ ├── Scene.h │ └── Part12_Tessellation.vcxproj.filters ├── Part13_Predication │ ├── Main.cpp │ ├── Scene.cpp │ ├── Shader │ │ ├── VSStreamOutput.hlsl │ │ ├── PixelShader.hlsl │ │ ├── VertexShader.hlsl │ │ └── GeometryShader.hlsl │ ├── Part13_Predication.vcxproj.filters │ └── Scene.h ├── Part15_Initialize │ ├── Main.cpp │ ├── Scene.cpp │ ├── Scene.h │ ├── Part15_Initialize.vcxproj.filters │ └── Part15_Initialize.vcxproj ├── Part02_ConstantBuffer │ ├── Main.cpp │ ├── Scene.cpp │ ├── Shader │ │ └── ClearScreen.hlsl │ ├── Scene.h │ └── Part02_ConstantBuffer.vcxproj.filters ├── Part10_GeometryShader │ ├── Main.cpp │ ├── Scene.cpp │ ├── Shader │ │ ├── VSDummy.hlsl │ │ ├── PixelShader.hlsl │ │ ├── VertexShader.hlsl │ │ ├── GeometryShader.hlsl │ │ └── GeometryShader2.hlsl │ ├── Part10_GeometryShader.vcxproj.filters │ └── Scene.h ├── Part13_DeferredContext │ ├── Scene.h │ ├── Main.cpp │ ├── Scene.cpp │ ├── Shader │ │ ├── PixelShader.hlsl │ │ └── VertexShader.hlsl │ └── Part13_DeferredContext.vcxproj.filters ├── Part17_TiledResource │ ├── Main.cpp │ ├── Scene.cpp │ ├── Shader │ │ └── CSDrawTexture.hlsl │ ├── Part17_TiledResource.vcxproj.filters │ └── Scene.h ├── Part05_GraphicsPipeline │ ├── Main.cpp │ ├── Scene.cpp │ ├── Shader │ │ ├── VertexShader.hlsl │ │ └── PixelShader.hlsl │ ├── Scene.h │ └── Part05_GraphicsPipeline.vcxproj.filters ├── Part09_RasterizerState │ ├── Main.cpp │ ├── Scene.cpp │ ├── Shader │ │ ├── PixelShader.hlsl │ │ └── VertexShader.hlsl │ ├── Part09_RasterizerState.vcxproj.filters │ └── Scene.h ├── Part07_RenderTargetAndBlendState │ ├── Main.cpp │ ├── Scene.cpp │ ├── Shader │ │ ├── PixelShader.hlsl │ │ └── VertexShader.hlsl │ ├── Part07_RenderTargetAndBlendState.vcxproj.filters │ └── Scene.h └── Part08_ZBufferAndDepthStencilState │ ├── Main.cpp │ ├── Scene.cpp │ ├── Shader │ ├── PixelShader.hlsl │ ├── PSEarlyZ.hlsl │ ├── VSLargeTriangle.hlsl │ └── VertexShader.hlsl │ ├── Part08_ZBufferAndDepthStencilState.vcxproj.filters │ └── Scene.h ├── .gitmodules ├── README.md ├── LICENSE ├── .gitattributes └── .gitignore /Project/Template/Common.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Template/Common.h -------------------------------------------------------------------------------- /Project/Part03_Texture/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part03_Texture/Main.cpp -------------------------------------------------------------------------------- /Project/Part06_DrawCall/Scene.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part06_DrawCall/Scene.h -------------------------------------------------------------------------------- /Project/Part14_Query/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part14_Query/Main.cpp -------------------------------------------------------------------------------- /Project/Part14_Query/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part14_Query/Scene.cpp -------------------------------------------------------------------------------- /Project/Template/DXSample.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Template/DXSample.cpp -------------------------------------------------------------------------------- /Project/Part03_Texture/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part03_Texture/Scene.cpp -------------------------------------------------------------------------------- /Project/Part03_Texture/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part03_Texture/image.png -------------------------------------------------------------------------------- /Project/Part06_DrawCall/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part06_DrawCall/Main.cpp -------------------------------------------------------------------------------- /Project/Part06_DrawCall/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part06_DrawCall/Scene.cpp -------------------------------------------------------------------------------- /Project/Part16_Texture2/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part16_Texture2/Main.cpp -------------------------------------------------------------------------------- /Project/Part16_Texture2/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part16_Texture2/Scene.cpp -------------------------------------------------------------------------------- /Project/Part01_ClearScreen/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part01_ClearScreen/Main.cpp -------------------------------------------------------------------------------- /Project/Part01_ClearScreen/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part01_ClearScreen/Scene.cpp -------------------------------------------------------------------------------- /Project/Part04_TypeOfBuffer/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part04_TypeOfBuffer/Main.cpp -------------------------------------------------------------------------------- /Project/Part11_StreamOutput/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part11_StreamOutput/Main.cpp -------------------------------------------------------------------------------- /Project/Part12_Tessellation/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part12_Tessellation/Main.cpp -------------------------------------------------------------------------------- /Project/Part13_Predication/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part13_Predication/Main.cpp -------------------------------------------------------------------------------- /Project/Part13_Predication/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part13_Predication/Scene.cpp -------------------------------------------------------------------------------- /Project/Part15_Initialize/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part15_Initialize/Main.cpp -------------------------------------------------------------------------------- /Project/Part15_Initialize/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part15_Initialize/Scene.cpp -------------------------------------------------------------------------------- /Project/Part02_ConstantBuffer/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part02_ConstantBuffer/Main.cpp -------------------------------------------------------------------------------- /Project/Part04_TypeOfBuffer/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part04_TypeOfBuffer/Scene.cpp -------------------------------------------------------------------------------- /Project/Part10_GeometryShader/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part10_GeometryShader/Main.cpp -------------------------------------------------------------------------------- /Project/Part11_StreamOutput/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part11_StreamOutput/Scene.cpp -------------------------------------------------------------------------------- /Project/Part12_Tessellation/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part12_Tessellation/Scene.cpp -------------------------------------------------------------------------------- /Project/Part13_DeferredContext/Scene.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part13_DeferredContext/Scene.h -------------------------------------------------------------------------------- /Project/Part17_TiledResource/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part17_TiledResource/Main.cpp -------------------------------------------------------------------------------- /Project/Part17_TiledResource/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part17_TiledResource/Scene.cpp -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Microsoft/DirectXTK"] 2 | path = Microsoft/DirectXTK 3 | url = https://github.com/Microsoft/DirectXTK.git 4 | -------------------------------------------------------------------------------- /Project/Part02_ConstantBuffer/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part02_ConstantBuffer/Scene.cpp -------------------------------------------------------------------------------- /Project/Part05_GraphicsPipeline/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part05_GraphicsPipeline/Main.cpp -------------------------------------------------------------------------------- /Project/Part05_GraphicsPipeline/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part05_GraphicsPipeline/Scene.cpp -------------------------------------------------------------------------------- /Project/Part09_RasterizerState/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part09_RasterizerState/Main.cpp -------------------------------------------------------------------------------- /Project/Part09_RasterizerState/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part09_RasterizerState/Scene.cpp -------------------------------------------------------------------------------- /Project/Part10_GeometryShader/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part10_GeometryShader/Scene.cpp -------------------------------------------------------------------------------- /Project/Part13_DeferredContext/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part13_DeferredContext/Main.cpp -------------------------------------------------------------------------------- /Project/Part13_DeferredContext/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part13_DeferredContext/Scene.cpp -------------------------------------------------------------------------------- /Project/Part12_Tessellation/Shader/DSQuad.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part12_Tessellation/Shader/DSQuad.hlsl -------------------------------------------------------------------------------- /Project/Part12_Tessellation/Shader/HSQuad.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part12_Tessellation/Shader/HSQuad.hlsl -------------------------------------------------------------------------------- /Project/Part16_Texture2/Shader/CSArrayRead.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part16_Texture2/Shader/CSArrayRead.hlsl -------------------------------------------------------------------------------- /Project/Part16_Texture2/Shader/CSArrayWrite.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part16_Texture2/Shader/CSArrayWrite.hlsl -------------------------------------------------------------------------------- /Project/Part16_Texture2/Shader/CSMipmapRead.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part16_Texture2/Shader/CSMipmapRead.hlsl -------------------------------------------------------------------------------- /Project/Part16_Texture2/Shader/CSUseCubemap.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part16_Texture2/Shader/CSUseCubemap.hlsl -------------------------------------------------------------------------------- /Project/Part01_ClearScreen/Shader/ClearScreen.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part01_ClearScreen/Shader/ClearScreen.hlsl -------------------------------------------------------------------------------- /Project/Part07_RenderTargetAndBlendState/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part07_RenderTargetAndBlendState/Main.cpp -------------------------------------------------------------------------------- /Project/Part07_RenderTargetAndBlendState/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part07_RenderTargetAndBlendState/Scene.cpp -------------------------------------------------------------------------------- /Project/Part08_ZBufferAndDepthStencilState/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part08_ZBufferAndDepthStencilState/Main.cpp -------------------------------------------------------------------------------- /Project/Part12_Tessellation/Shader/DSIsoline.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part12_Tessellation/Shader/DSIsoline.hlsl -------------------------------------------------------------------------------- /Project/Part12_Tessellation/Shader/DSTriangle.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part12_Tessellation/Shader/DSTriangle.hlsl -------------------------------------------------------------------------------- /Project/Part12_Tessellation/Shader/HSIsoline.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part12_Tessellation/Shader/HSIsoline.hlsl -------------------------------------------------------------------------------- /Project/Part12_Tessellation/Shader/HSTriangle.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part12_Tessellation/Shader/HSTriangle.hlsl -------------------------------------------------------------------------------- /Project/Part16_Texture2/Shader/CSMipmapWrite.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part16_Texture2/Shader/CSMipmapWrite.hlsl -------------------------------------------------------------------------------- /Project/Part16_Texture2/Shader/GSRenderCubemap.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part16_Texture2/Shader/GSRenderCubemap.hlsl -------------------------------------------------------------------------------- /Project/Part08_ZBufferAndDepthStencilState/Scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part08_ZBufferAndDepthStencilState/Scene.cpp -------------------------------------------------------------------------------- /Project/Part06_DrawCall/Shader/VertexShaderWithSlot.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part06_DrawCall/Shader/VertexShaderWithSlot.hlsl -------------------------------------------------------------------------------- /Project/Part17_TiledResource/Shader/CSDrawTexture.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part17_TiledResource/Shader/CSDrawTexture.hlsl -------------------------------------------------------------------------------- /Project/Part03_Texture/Shader/ClearScreenWithSampler.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part03_Texture/Shader/ClearScreenWithSampler.hlsl -------------------------------------------------------------------------------- /Project/Part12_Tessellation/Shader/DSPointToTriangle.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part12_Tessellation/Shader/DSPointToTriangle.hlsl -------------------------------------------------------------------------------- /Project/Part12_Tessellation/Shader/HSPointToTriangle.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part12_Tessellation/Shader/HSPointToTriangle.hlsl -------------------------------------------------------------------------------- /Project/Part04_TypeOfBuffer/Shader/RenderSphereByConstantBuffer.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part04_TypeOfBuffer/Shader/RenderSphereByConstantBuffer.hlsl -------------------------------------------------------------------------------- /Project/Part04_TypeOfBuffer/Shader/RenderSphereByByteAddressBuffer.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part04_TypeOfBuffer/Shader/RenderSphereByByteAddressBuffer.hlsl -------------------------------------------------------------------------------- /Project/Part04_TypeOfBuffer/Shader/RenderSphereByStructuredBuffer.hlsl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tositeru/ImasaraDX11/HEAD/Project/Part04_TypeOfBuffer/Shader/RenderSphereByStructuredBuffer.hlsl -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # いまさらDirect3D11入門 2 | このリポジトリは初めてグラフィックスAPIを触る人に向けて、Direct3D11の各種機能について説明することを目的にしたものです。 3 | 4 | 又、Direct3D12を触る前の前提知識になることを目指しています。 5 | 6 | ここではDirect3D11に関係することのみ説明し、3Dグラフィックにつきものの、数学やアルゴリズム、モデルファイル等は極力触れません。 7 | 8 | サンプルコードはクラスや列挙型、例外などの簡単なC++のコードが読めることを想定しています。 9 | 10 | サンプルコードの解説は[Github page](https://tositeru.github.io/ImasaraDX11/index.html)にあります。 11 | 12 | ## 実行環境 13 | 14 | サンプルコードの実行環境は以下のものを想定しています。 15 | 16 | * OS : Windows10 17 | * IDE : Visual Studio 2015 18 | * GPU : Direct3D11対応のGPU 19 | * 最新のWindows 10 SDKをインストールしていること 20 | 21 | サンプルコードではDirectXTKを使用しています。 22 | githubからクローンした後、サブモジュールの更新を行ってください。 23 | 24 | サブモジュールの更新の仕方はGit Bashを起動し以下のコマンドを実行してください。 25 | 26 | git submodule update 27 | 28 | 29 | コンパイルができない場合は各プロジェクトのプロパティを開き(全般) -> (ターゲットプラットフォームバージョン)をインストールしたWindows 10 SDKのバージョンに合わせてください 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 tositeru 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Project/Part16_Texture2/Shader/VSDummy.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | void main() 22 | {} -------------------------------------------------------------------------------- /Project/Part10_GeometryShader/Shader/VSDummy.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | void main() 22 | {} -------------------------------------------------------------------------------- /Project/Part12_Tessellation/Shader/VS.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | float4 main(float4 pos : POSITION) : POSITION 22 | { 23 | return pos; 24 | } 25 | -------------------------------------------------------------------------------- /Project/Part14_Query/Shader/VSStreamOutput.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | 22 | uint main( uint id : SV_VertexID ) : ID 23 | { 24 | return id; 25 | } -------------------------------------------------------------------------------- /Project/Part11_StreamOutput/Shader/VSStreamOutput.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | 22 | uint main( uint id : SV_VertexID ) : ID 23 | { 24 | return id; 25 | } -------------------------------------------------------------------------------- /Project/Part13_Predication/Shader/VSStreamOutput.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | 22 | uint main( uint id : SV_VertexID ) : ID 23 | { 24 | return id; 25 | } -------------------------------------------------------------------------------- /Project/Part05_GraphicsPipeline/Shader/VertexShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | float4 main( float4 pos : POSITION ) : SV_POSITION 22 | { 23 | return pos; 24 | } -------------------------------------------------------------------------------- /Project/Part06_DrawCall/Shader/PixelShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | float4 main(float4 pos : SV_POSITION, float4 color : COLOR0) : SV_TARGET 22 | { 23 | return color; 24 | } -------------------------------------------------------------------------------- /Project/Part12_Tessellation/Shader/PixelShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | float4 main(float4 pos : SV_POSITION, float4 color : TEXCOORD0) : SV_Target 22 | { 23 | return color; 24 | } -------------------------------------------------------------------------------- /Project/Part13_DeferredContext/Shader/PixelShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | float4 main(float4 pos : SV_POSITION, float4 color : COLOR0) : SV_TARGET 22 | { 23 | return color; 24 | } -------------------------------------------------------------------------------- /Project/Part05_GraphicsPipeline/Shader/PixelShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | float4 main(float4 pos : SV_POSITION) : SV_TARGET 22 | { 23 | return float4(1.0f, 1.0f, 1.0f, 1.0f); 24 | } -------------------------------------------------------------------------------- /Project/Part14_Query/Shader/PixelShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | void main(float4 pos : SV_POSITION, float4 color : TEXCOORD0, out float4 outColor : SV_Target0) 22 | { 23 | outColor = color; 24 | } -------------------------------------------------------------------------------- /Project/Part09_RasterizerState/Shader/PixelShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | void main(float4 pos : SV_POSITION, float4 color : COLOR0, out float4 outColor : SV_Target0) 22 | { 23 | outColor = color; 24 | } -------------------------------------------------------------------------------- /Project/Part10_GeometryShader/Shader/PixelShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | void main(float4 pos : SV_POSITION, float4 color : COLOR0, out float4 outColor : SV_Target0) 22 | { 23 | outColor = color; 24 | } -------------------------------------------------------------------------------- /Project/Part11_StreamOutput/Shader/PixelShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | void main(float4 pos : SV_POSITION, float4 color : TEXCOORD0, out float4 outColor : SV_Target0) 22 | { 23 | outColor = color; 24 | } -------------------------------------------------------------------------------- /Project/Part13_Predication/Shader/PixelShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | void main(float4 pos : SV_POSITION, float4 color : TEXCOORD0, out float4 outColor : SV_Target0) 22 | { 23 | outColor = color; 24 | } -------------------------------------------------------------------------------- /Project/Part08_ZBufferAndDepthStencilState/Shader/PixelShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | void main(float4 pos : SV_POSITION, float4 color : COLOR0, out float4 outColor : SV_Target0) 22 | { 23 | outColor = color; 24 | } -------------------------------------------------------------------------------- /Project/Part08_ZBufferAndDepthStencilState/Shader/PSEarlyZ.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | [earlydepthstencil] 22 | void main(float4 pos : SV_POSITION, float4 color : COLOR0, out float4 outColor : SV_Target0) 23 | { 24 | outColor = color; 25 | } -------------------------------------------------------------------------------- /Project/Part07_RenderTargetAndBlendState/Shader/PixelShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | void main( 22 | float4 pos : SV_POSITION, 23 | float4 color : COLOR0, 24 | out float4 outColor : SV_Target0, 25 | out float4 outColor2 : SV_Target1) 26 | { 27 | outColor = color; 28 | outColor2 = color; 29 | } -------------------------------------------------------------------------------- /Project/Part16_Texture2/Shader/PSRenderCubemap.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | struct PSInput { 22 | float4 pos : SV_POSITION; 23 | float4 color : TEXCOORD0; 24 | uint arrayIndex : SV_RenderTargetArrayIndex; 25 | }; 26 | 27 | float4 main(PSInput input) : SV_TARGET 28 | { 29 | return input.color; 30 | } -------------------------------------------------------------------------------- /Project/Part16_Texture2/Shader/PSRenderMultisampling.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | struct PSInput { 22 | float4 pos : SV_POSITION; 23 | float4 color : TEXCOORD0; 24 | uint sampleIndex : SV_SampleIndex; 25 | }; 26 | 27 | float4 main(PSInput input) : SV_TARGET 28 | { 29 | return input.color; 30 | } -------------------------------------------------------------------------------- /Project/Part10_GeometryShader/Shader/VertexShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | struct Input 22 | { 23 | float4 pos : POSITION; 24 | }; 25 | 26 | struct Output 27 | { 28 | float4 pos : POSITION; 29 | }; 30 | 31 | Output main(Input input) 32 | { 33 | Output output; 34 | output.pos = input.pos; 35 | return output; 36 | } -------------------------------------------------------------------------------- /Project/Part04_TypeOfBuffer/Shader/PopStack.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | ConsumeStructuredBuffer stack : register(u0); 22 | RWStructuredBuffer buffer : register(u1); 23 | 24 | [numthreads(1, 1, 1)] 25 | void main( uint3 DTid : SV_DispatchThreadID ) 26 | { 27 | [branch] if (DTid.x < 10) { 28 | buffer[DTid.x] = stack.Consume(); 29 | } 30 | } -------------------------------------------------------------------------------- /Project/Part06_DrawCall/Shader/VertexShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | 22 | static float4 gColor = float4(1, 0.7f, 1, 1); 23 | 24 | struct Output 25 | { 26 | float4 pos : SV_POSITION; 27 | float4 color : COLOR0; 28 | }; 29 | 30 | Output main( float4 pos : POSITION ) 31 | { 32 | Output output; 33 | output.pos = pos; 34 | output.color = gColor; 35 | return output; 36 | } -------------------------------------------------------------------------------- /Project/Part13_DeferredContext/Shader/VertexShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | 22 | static float4 gColor = float4(1, 0.7f, 1, 1); 23 | 24 | struct Output 25 | { 26 | float4 pos : SV_POSITION; 27 | float4 color : COLOR0; 28 | }; 29 | 30 | Output main( float4 pos : POSITION ) 31 | { 32 | Output output; 33 | output.pos = pos; 34 | output.color = gColor; 35 | return output; 36 | } -------------------------------------------------------------------------------- /Project/Part08_ZBufferAndDepthStencilState/Shader/VSLargeTriangle.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | struct Input 22 | { 23 | float4 pos : POSITION; 24 | }; 25 | 26 | struct Output 27 | { 28 | float4 pos : SV_POSITION; 29 | float4 color : COLOR0; 30 | }; 31 | 32 | Output main(Input input) 33 | { 34 | Output output; 35 | output.pos = input.pos; 36 | output.color = 1; 37 | return output; 38 | } -------------------------------------------------------------------------------- /Project/Part14_Query/Shader/VertexShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | struct Input 22 | { 23 | float4 pos : POSITION; 24 | float4 color : TEXCOORD0; 25 | }; 26 | 27 | struct Output 28 | { 29 | float4 pos : SV_POSITION; 30 | float4 color : TEXCOORD0; 31 | }; 32 | 33 | Output main(Input input) 34 | { 35 | Output output; 36 | output.pos = input.pos; 37 | output.color = input.color; 38 | return output; 39 | } -------------------------------------------------------------------------------- /Project/Part11_StreamOutput/Shader/VertexShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | struct Input 22 | { 23 | float4 pos : POSITION; 24 | float4 color : TEXCOORD0; 25 | }; 26 | 27 | struct Output 28 | { 29 | float4 pos : SV_POSITION; 30 | float4 color : TEXCOORD0; 31 | }; 32 | 33 | Output main(Input input) 34 | { 35 | Output output; 36 | output.pos = input.pos; 37 | output.color = input.color; 38 | return output; 39 | } -------------------------------------------------------------------------------- /Project/Part13_Predication/Shader/VertexShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | struct Input 22 | { 23 | float4 pos : POSITION; 24 | float4 color : TEXCOORD0; 25 | }; 26 | 27 | struct Output 28 | { 29 | float4 pos : SV_POSITION; 30 | float4 color : TEXCOORD0; 31 | }; 32 | 33 | Output main(Input input) 34 | { 35 | Output output; 36 | output.pos = input.pos; 37 | output.color = input.color; 38 | return output; 39 | } -------------------------------------------------------------------------------- /Project/Part02_ConstantBuffer/Shader/ClearScreen.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | cbuffer Param : register(b0) 22 | { 23 | float4 clearColor; 24 | uint2 screenSize; 25 | }; 26 | 27 | RWTexture2D screen : register(u0); 28 | 29 | [numthreads(1, 1, 1)] 30 | void main( uint2 DTid : SV_DispatchThreadID ) 31 | { 32 | if(DTid.x < screenSize.x && DTid.y < screenSize.y) { 33 | screen[DTid] = clearColor; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Project/Part09_RasterizerState/Shader/VertexShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | struct Input 22 | { 23 | float4 pos : POSITION; 24 | uint id : SV_VertexID; 25 | }; 26 | 27 | struct Output 28 | { 29 | float4 pos : SV_POSITION; 30 | float4 color : COLOR0; 31 | }; 32 | 33 | Output main(Input input) 34 | { 35 | Output output; 36 | output.pos = input.pos; 37 | output.color = input.id % 6 < 3 ? float4(1,1,0.4f,1) : float4(1, 0.7f, 1, 1); 38 | 39 | return output; 40 | } -------------------------------------------------------------------------------- /Project/Template/Win32Application.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include "DXSample.h" 24 | 25 | class DXSample; 26 | 27 | class Win32Application 28 | { 29 | public: 30 | static int run(DXSample* pSample, HINSTANCE hInstance, int nCmdShow); 31 | static HWND hwnd() { return sHwnd; } 32 | 33 | protected: 34 | static LRESULT CALLBACK windowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 35 | 36 | private: 37 | static HWND sHwnd; 38 | }; 39 | -------------------------------------------------------------------------------- /Project/Part03_Texture/Shader/ClearScreenWithTexture.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | Texture2D image : register(t0); 22 | 23 | RWTexture2D screen : register(u0); 24 | 25 | [numthreads(1, 1, 1)] 26 | void main(uint2 DTid : SV_DispatchThreadID) 27 | { 28 | uint2 image_size; 29 | image.GetDimensions(image_size.x, image_size.y); 30 | 31 | [branch] 32 | if (DTid.x < image_size.x && DTid.y < image_size.y) { 33 | screen[DTid] = image[DTid]; 34 | } else { 35 | screen[DTid] = float4(0, 0, 0, 1); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Project/Part16_Texture2/Shader/ClearScreenWithSampler.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | Texture2D image : register(t0); 22 | 23 | SamplerState point_sampler : register(s0); 24 | 25 | RWTexture2D screen : register(u0); 26 | 27 | [numthreads(1, 1, 1)] 28 | void main(uint2 DTid : SV_DispatchThreadID) 29 | { 30 | uint2 screen_size; 31 | screen.GetDimensions(screen_size.x, screen_size.y); 32 | 33 | float2 uv = (float2)DTid / (float2)screen_size; 34 | screen[DTid] = image.SampleLevel(point_sampler, uv, 0); 35 | } 36 | -------------------------------------------------------------------------------- /Project/Part04_TypeOfBuffer/Shader/PushStack.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | AppendStructuredBuffer stack : register(u0); 22 | 23 | #define COLOR_COUNT 10 24 | static const float4 tblColor[COLOR_COUNT] = { 25 | float4(1, 0, 0, 1), 26 | float4(0, 1, 0, 1), 27 | float4(0, 0, 1, 1), 28 | float4(1, 1, 0, 1), 29 | float4(1, 0, 1, 1), 30 | float4(0, 1, 1, 1), 31 | float4(0, 0, 0, 1), 32 | float4(1, 1, 1, 1), 33 | float4(1, 0.5f, 0, 1), 34 | float4(1, 0, 0.5f, 1), 35 | }; 36 | 37 | [numthreads(1, 1, 1)] 38 | void main( uint3 DTid : SV_DispatchThreadID ) 39 | { 40 | uint index = DTid.x % COLOR_COUNT; 41 | stack.Append(tblColor[index]); 42 | } 43 | -------------------------------------------------------------------------------- /Project/Part01_ClearScreen/Scene.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include "Template/DXSample.h" 24 | 25 | class Scene : public DXSample 26 | { 27 | public: 28 | Scene(UINT width, UINT height, std::wstring name); 29 | 30 | virtual void onInit()override; 31 | virtual void onUpdate()override; 32 | virtual void onRender()override; 33 | virtual void onDestroy()override; 34 | 35 | virtual void onKeyUp(UINT8 key)override; 36 | 37 | private: 38 | Microsoft::WRL::ComPtr mpCSClearScreen; 39 | 40 | Microsoft::WRL::ComPtr mpScreen; 41 | Microsoft::WRL::ComPtr mpScreenUAV; 42 | }; 43 | -------------------------------------------------------------------------------- /Project/Part15_Initialize/Scene.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include "Template/DXSample.h" 24 | 25 | class Scene : public DXSample 26 | { 27 | public: 28 | Scene(UINT width, UINT height, std::wstring name); 29 | 30 | virtual void onInit()override; 31 | virtual void onUpdate()override; 32 | virtual void onRender()override; 33 | virtual void onDestroy()override; 34 | virtual void onResizeWindow(WPARAM wParam, UINT width, UINT height); 35 | 36 | virtual void onKeyUp(UINT8 key)override; 37 | 38 | private: 39 | void initRenderTargetAndDepthStencil(UINT width, UINT height); 40 | 41 | private: 42 | Microsoft::WRL::ComPtr mpAdapter; 43 | }; 44 | -------------------------------------------------------------------------------- /Project/Part07_RenderTargetAndBlendState/Shader/VertexShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | 22 | struct InstancedParam { 23 | float3 offset; 24 | float pad; 25 | float4 color; 26 | }; 27 | StructuredBuffer offsets : register(t0); 28 | 29 | struct Input 30 | { 31 | float4 pos : POSITION; 32 | uint instanceID : SV_InstanceID; 33 | }; 34 | 35 | struct Output 36 | { 37 | float4 pos : SV_POSITION; 38 | float4 color : COLOR0; 39 | }; 40 | 41 | Output main(Input input) 42 | { 43 | Output output; 44 | output.pos = input.pos; 45 | output.pos.xyz *= 0.5f; 46 | output.pos.xyz += offsets[input.instanceID].offset; 47 | output.color = offsets[input.instanceID].color; 48 | 49 | return output; 50 | } -------------------------------------------------------------------------------- /Project/Part08_ZBufferAndDepthStencilState/Shader/VertexShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | 22 | struct InstancedParam { 23 | float3 offset; 24 | float pad; 25 | float4 color; 26 | }; 27 | StructuredBuffer offsets : register(t0); 28 | 29 | struct Input 30 | { 31 | float4 pos : POSITION; 32 | uint instanceID : SV_InstanceID; 33 | }; 34 | 35 | struct Output 36 | { 37 | float4 pos : SV_POSITION; 38 | float4 color : COLOR0; 39 | }; 40 | 41 | Output main(Input input) 42 | { 43 | Output output; 44 | output.pos = input.pos; 45 | output.pos.xyz *= 0.5f; 46 | output.pos.xyz += offsets[input.instanceID].offset; 47 | output.color = offsets[input.instanceID].color; 48 | 49 | return output; 50 | } -------------------------------------------------------------------------------- /Project/Part10_GeometryShader/Shader/GeometryShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | struct GSOutput 22 | { 23 | float4 pos : SV_POSITION; 24 | float4 color : COLOR0; 25 | }; 26 | 27 | static const float4 trianglePos[3] = { 28 | float4(0.f, 0.5f, 0.f, 0.f), 29 | float4(0.5f, -0.5f, 0.f, 0.f), 30 | float4(-0.5f, -0.5f, 0.f, 0.f), 31 | }; 32 | 33 | [maxvertexcount(3)] 34 | void main( 35 | point float4 input[1] : POSITION, 36 | inout TriangleStream< GSOutput > output 37 | ) 38 | { 39 | [unroll] for (uint i = 0; i < 3; i++) 40 | { 41 | GSOutput element; 42 | element.pos = input[0] + trianglePos[i]; 43 | element.color = float4(1.0f, 1.0f, 0.3f, 1.f); 44 | output.Append(element); 45 | } 46 | output.RestartStrip(); 47 | } -------------------------------------------------------------------------------- /Project/Part06_DrawCall/Shader/VertexShaderWithStructuredBuffer.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | static float4 gColor = float4(1, 1, 1, 1); 22 | 23 | struct InstancedParam { 24 | float3 offset; 25 | }; 26 | StructuredBuffer offsets : register(t0); 27 | 28 | struct Input 29 | { 30 | float4 pos : POSITION; 31 | uint instanceID : SV_InstanceID; 32 | }; 33 | 34 | struct Output 35 | { 36 | float4 pos : SV_POSITION; 37 | float4 color : COLOR0; 38 | }; 39 | 40 | Output main(Input input) 41 | { 42 | Output output; 43 | output.pos = input.pos; 44 | output.pos.xyz *= 0.05f; 45 | output.pos.xyz += offsets[input.instanceID].offset; 46 | output.color = gColor; 47 | output.color.rgb *= offsets[input.instanceID].offset; 48 | 49 | return output; 50 | } -------------------------------------------------------------------------------- /Project/Part15_Initialize/Part15_Initialize.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {ec2385f2-74d5-4caf-9728-6378b836b1d9} 18 | 19 | 20 | 21 | 22 | ソース ファイル 23 | 24 | 25 | ソース ファイル 26 | 27 | 28 | ソース ファイル\Template 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | 35 | 36 | ソース ファイル 37 | 38 | 39 | ソース ファイル\Template 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル\Template 46 | 47 | 48 | -------------------------------------------------------------------------------- /Project/Part10_GeometryShader/Shader/GeometryShader2.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | struct DummyInput { 22 | }; 23 | 24 | struct GSOutput 25 | { 26 | float4 pos : SV_POSITION; 27 | float4 color : COLOR0; 28 | }; 29 | 30 | static const float4 trianglePos[3] = { 31 | float4(0.f, 0.5f, 0.f, 1.f), 32 | float4(0.5f, -0.5f, 0.f, 1.f), 33 | float4(-0.5f, -0.5f, 0.f, 1.f), 34 | }; 35 | 36 | 37 | [maxvertexcount(3)] 38 | void main( 39 | point DummyInput input[1] : POSITION, 40 | in uint id : SV_PrimitiveID, 41 | inout TriangleStream< GSOutput > output 42 | ) 43 | { 44 | [unroll] for (uint i = 0; i < 3; i++) { 45 | GSOutput element; 46 | element.pos = trianglePos[i]; 47 | element.color = float4(0.3f, 1.0f, 1.0f, 1.f); 48 | output.Append(element); 49 | } 50 | } -------------------------------------------------------------------------------- /Project/Part16_Texture2/Shader/Common.hlsli: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | float4 calRayDir(in uint2 DTid, in float2 screenSize, in float4x4 invProjection) 22 | { 23 | float4 rayDir; 24 | rayDir.xy = (DTid / screenSize) * float2(2, -2) + float2(-1, 1); 25 | rayDir.zw = 1; 26 | 27 | rayDir = mul(rayDir, invProjection); 28 | rayDir /= rayDir.w; 29 | rayDir.xyz = normalize(rayDir.xyz); 30 | return rayDir; 31 | } 32 | 33 | float4 calColor(float3 rayDir, float3 spherePos, float sphereRange, float3 color) 34 | { 35 | float3 p = rayDir.xyz * dot(rayDir.xyz, spherePos); 36 | float len = distance(p, spherePos); 37 | [branch] if (len < sphereRange) { 38 | return float4(color * ((1 - saturate(len / sphereRange))*0.8f + 0.2f), 1); 39 | } else { 40 | return float4(0, 0.125f, 0.2f, 1); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Project/Part04_TypeOfBuffer/Shader/Common.hlsli: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | float4 calRayDir(in uint2 DTid, in float2 screenSize, in float4x4 invProjection) 22 | { 23 | float4 rayDir; 24 | rayDir.xy = (DTid / screenSize) * float2(2, -2) + float2(-1, 1); 25 | rayDir.zw = 1; 26 | 27 | rayDir = mul(rayDir, invProjection); 28 | rayDir /= rayDir.w; 29 | rayDir.xyz = normalize(rayDir.xyz); 30 | return rayDir; 31 | } 32 | 33 | float4 calColor(float3 rayDir, float3 spherePos, float sphereRange, float3 color) 34 | { 35 | float3 p = rayDir.xyz * dot(rayDir.xyz, spherePos); 36 | float len = distance(p, spherePos); 37 | [branch] if (len < sphereRange) { 38 | return float4(color * ((1 - saturate(len / sphereRange))*0.8f + 0.2f), 1); 39 | } else { 40 | return float4(0, 0.125f, 0.2f, 1); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Project/Part16_Texture2/Shader/GSRenderMultisampling.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | struct Dummy {}; 22 | 23 | struct GSOutput 24 | { 25 | float4 pos : SV_POSITION; 26 | float4 color : TEXCOORD0; 27 | }; 28 | 29 | static const float4 gColorTable[6] = { 30 | float4(1.0f, 0.7f, 0.7f, 1), 31 | float4(0.7f, 1.0f, 0.7f, 1), 32 | float4(0.7f, 0.7f, 1.0f, 1), 33 | float4(1.0f, 1.0f, 0.7f, 1), 34 | float4(1.0f, 0.7f, 1.0f, 1), 35 | float4(0.7f, 1.0f, 1.0f, 1), 36 | }; 37 | 38 | static const float4 gPosTable[3] = { 39 | float4(0.0f, 0.5f, 0.0f, 1.0f), 40 | float4(0.5f,-0.5f, 0.0f, 1.0f), 41 | float4(-0.5f,-0.5f, 0.0f, 1.0f), 42 | }; 43 | 44 | [maxvertexcount(3)] 45 | void main( 46 | point Dummy input[1], 47 | inout TriangleStream< GSOutput > output 48 | ) 49 | { 50 | [unroll] for (uint i = 0; i < 3; i++) { 51 | GSOutput element; 52 | element.pos = gPosTable[i]; 53 | element.color = gColorTable[0]; 54 | output.Append(element); 55 | } 56 | output.RestartStrip(); 57 | } -------------------------------------------------------------------------------- /Project/Part02_ConstantBuffer/Scene.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include 24 | #include "Template/DXSample.h" 25 | 26 | class Scene : public DXSample 27 | { 28 | public: 29 | Scene(UINT width, UINT height, std::wstring name); 30 | 31 | virtual void onInit()override; 32 | virtual void onUpdate()override; 33 | virtual void onRender()override; 34 | virtual void onDestroy()override; 35 | 36 | virtual void onKeyUp(UINT8 key)override; 37 | 38 | private: 39 | struct Param { 40 | DirectX::SimpleMath::Vector4 clearColor; 41 | DirectX::SimpleMath::Vector2 screenSize; 42 | }; 43 | 44 | private: 45 | void updateTitle(); 46 | 47 | private: 48 | Microsoft::WRL::ComPtr mpCSClearScreen; 49 | 50 | Microsoft::WRL::ComPtr mpCB; 51 | Microsoft::WRL::ComPtr mpCBMappable; 52 | 53 | Microsoft::WRL::ComPtr mpScreen; 54 | Microsoft::WRL::ComPtr mpScreenUAV; 55 | }; 56 | -------------------------------------------------------------------------------- /Project/Part01_ClearScreen/Part01_ClearScreen.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {71961e9e-9123-4786-8a17-6475b909813c} 18 | 19 | 20 | {6c1f8f84-2253-4089-b4c5-8c1119b42463} 21 | 22 | 23 | 24 | 25 | ソース ファイル 26 | 27 | 28 | ソース ファイル 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | ソース ファイル\Template 35 | 36 | 37 | 38 | 39 | ソース ファイル 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル\Template 46 | 47 | 48 | ソース ファイル\Template 49 | 50 | 51 | 52 | 53 | ソース ファイル\Shader 54 | 55 | 56 | -------------------------------------------------------------------------------- /Project/Part02_ConstantBuffer/Part02_ConstantBuffer.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {d4b7d387-0d40-4605-ac56-92cc8affaddd} 18 | 19 | 20 | {73346676-fcc3-4838-8931-76b3837a8b74} 21 | 22 | 23 | 24 | 25 | ソース ファイル\Template 26 | 27 | 28 | ソース ファイル\Template 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | ソース ファイル 35 | 36 | 37 | 38 | 39 | ソース ファイル\Template 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル 46 | 47 | 48 | ソース ファイル 49 | 50 | 51 | 52 | 53 | ソース ファイル\Shader 54 | 55 | 56 | -------------------------------------------------------------------------------- /Project/Part17_TiledResource/Part17_TiledResource.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {efd6c45b-41ca-470e-976d-38c2d044c1df} 18 | 19 | 20 | {fbd546a5-db2b-4d96-b47d-a377bf9c0727} 21 | 22 | 23 | 24 | 25 | ソース ファイル 26 | 27 | 28 | ソース ファイル 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | ソース ファイル\Template 35 | 36 | 37 | 38 | 39 | ソース ファイル 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル\Template 46 | 47 | 48 | ソース ファイル\Template 49 | 50 | 51 | 52 | 53 | ソース ファイル\Shader 54 | 55 | 56 | -------------------------------------------------------------------------------- /Project/Part05_GraphicsPipeline/Scene.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include "Template/DXSample.h" 24 | #include 25 | 26 | class Scene : public DXSample 27 | { 28 | public: 29 | Scene(UINT width, UINT height, std::wstring name); 30 | 31 | virtual void onInit()override; 32 | virtual void onUpdate()override; 33 | virtual void onRender()override; 34 | virtual void onDestroy()override; 35 | 36 | virtual void onKeyUp(UINT8 key)override; 37 | 38 | private: 39 | struct Vertex { 40 | DirectX::SimpleMath::Vector3 pos; 41 | }; 42 | 43 | private: 44 | void updateTitle(); 45 | 46 | private: 47 | enum SHADER_MODE { 48 | eMODE_TRIANGLE, 49 | eMODE_LINE, 50 | eMODE_POINT, 51 | eMODE_COUNT, 52 | } mMode = eMODE_TRIANGLE; 53 | 54 | Microsoft::WRL::ComPtr mpVertexShader; 55 | Microsoft::WRL::ComPtr mpPixelShader; 56 | Microsoft::WRL::ComPtr mpTriangleBuffer; 57 | Microsoft::WRL::ComPtr mpPointBuffer; 58 | Microsoft::WRL::ComPtr mpLineBuffer; 59 | Microsoft::WRL::ComPtr mpInputLayout; 60 | }; 61 | -------------------------------------------------------------------------------- /Project/Part05_GraphicsPipeline/Part05_GraphicsPipeline.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {f8496203-cf38-4f70-84b0-cdf4b5e020f1} 18 | 19 | 20 | {24f1ca87-9a1e-47d2-a900-188dd2cee60c} 21 | 22 | 23 | 24 | 25 | ソース ファイル 26 | 27 | 28 | ソース ファイル 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | ソース ファイル\Template 35 | 36 | 37 | 38 | 39 | ソース ファイル 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル\Template 46 | 47 | 48 | ソース ファイル\Template 49 | 50 | 51 | 52 | 53 | ソース ファイル\Shader 54 | 55 | 56 | ソース ファイル\Shader 57 | 58 | 59 | -------------------------------------------------------------------------------- /Project/Part09_RasterizerState/Part09_RasterizerState.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {32089b44-87e8-4247-a88c-3ee11e0c2661} 18 | 19 | 20 | {4e6cae5d-3c4c-43ba-9098-bdd88c894a0c} 21 | 22 | 23 | 24 | 25 | ソース ファイル 26 | 27 | 28 | ソース ファイル 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | ソース ファイル\Template 35 | 36 | 37 | 38 | 39 | ソース ファイル 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル\Template 46 | 47 | 48 | ソース ファイル\Template 49 | 50 | 51 | 52 | 53 | ソース ファイル\Shader 54 | 55 | 56 | ソース ファイル\Shader 57 | 58 | 59 | -------------------------------------------------------------------------------- /Project/Part13_DeferredContext/Part13_DeferredContext.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {d4c65e49-dadf-4c61-b3d3-b585deaaa29a} 18 | 19 | 20 | {69307557-f42d-4579-9e3c-3e769300a0aa} 21 | 22 | 23 | 24 | 25 | ソース ファイル 26 | 27 | 28 | ソース ファイル 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | ソース ファイル\Template 35 | 36 | 37 | 38 | 39 | ソース ファイル 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル\Template 46 | 47 | 48 | ソース ファイル\Template 49 | 50 | 51 | 52 | 53 | ソース ファイル\Shader 54 | 55 | 56 | ソース ファイル\Shader 57 | 58 | 59 | -------------------------------------------------------------------------------- /Project/Part03_Texture/Part03_Texture.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {f1f18105-f0a2-4ff1-909c-5edbb39bec0c} 18 | 19 | 20 | {12a511e4-69bb-4cb4-a512-e94aaabc5bc7} 21 | 22 | 23 | 24 | 25 | ソース ファイル\Template 26 | 27 | 28 | ソース ファイル\Template 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | ソース ファイル 35 | 36 | 37 | 38 | 39 | ソース ファイル\Template 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル 46 | 47 | 48 | ソース ファイル 49 | 50 | 51 | 52 | 53 | ソース ファイル\Shader 54 | 55 | 56 | ソース ファイル\Shader 57 | 58 | 59 | -------------------------------------------------------------------------------- /Project/Part03_Texture/Scene.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include "Template/DXSample.h" 24 | 25 | class Scene : public DXSample 26 | { 27 | public: 28 | Scene(UINT width, UINT height, std::wstring name); 29 | 30 | virtual void onInit()override; 31 | virtual void onUpdate()override; 32 | virtual void onRender()override; 33 | virtual void onDestroy()override; 34 | 35 | virtual void onKeyUp(UINT8 key)override; 36 | 37 | private: 38 | void updateTitle(); 39 | 40 | private: 41 | enum SHADER_MODE { 42 | eMODE_INDEX, 43 | eMODE_SAMPLER, 44 | eMODE_COUNT, 45 | } mMode = eMODE_INDEX; 46 | 47 | Microsoft::WRL::ComPtr mpCSClearScreen; 48 | Microsoft::WRL::ComPtr mpCSClearScreenWithSampler; 49 | 50 | Microsoft::WRL::ComPtr mpTex2D; 51 | Microsoft::WRL::ComPtr mpTex2DSRV; 52 | Microsoft::WRL::ComPtr mpImage; 53 | Microsoft::WRL::ComPtr mpImageSRV; 54 | Microsoft::WRL::ComPtr mpSampler; 55 | 56 | Microsoft::WRL::ComPtr mpScreen; 57 | Microsoft::WRL::ComPtr mpScreenUAV; 58 | }; 59 | -------------------------------------------------------------------------------- /Project/Part07_RenderTargetAndBlendState/Part07_RenderTargetAndBlendState.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {de74b356-6280-40ef-ba86-2fc689776338} 18 | 19 | 20 | {546b4430-6e9e-4140-bfa4-a785591b8ee9} 21 | 22 | 23 | 24 | 25 | ソース ファイル 26 | 27 | 28 | ソース ファイル 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | ソース ファイル\Template 35 | 36 | 37 | 38 | 39 | ソース ファイル 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル\Template 46 | 47 | 48 | ソース ファイル\Template 49 | 50 | 51 | 52 | 53 | ソース ファイル\Shader 54 | 55 | 56 | ソース ファイル\Shader 57 | 58 | 59 | -------------------------------------------------------------------------------- /Project/Part11_StreamOutput/Scene.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include "Template/DXSample.h" 24 | #include 25 | 26 | class Scene : public DXSample 27 | { 28 | public: 29 | Scene(UINT width, UINT height, std::wstring name); 30 | 31 | virtual void onInit()override; 32 | virtual void onUpdate()override; 33 | virtual void onRender()override; 34 | virtual void onDestroy()override; 35 | 36 | virtual void onKeyUp(UINT8 key)override; 37 | 38 | private: 39 | struct Vertex { 40 | DirectX::SimpleMath::Vector3 pos; 41 | DirectX::SimpleMath::Vector4 color; 42 | }; 43 | 44 | 45 | private: 46 | static const UINT M_STREAM_OUTPUT_COUNT = 100 * 3; 47 | 48 | Microsoft::WRL::ComPtr mpVSStreamOutput; 49 | Microsoft::WRL::ComPtr mpGeometryShader; 50 | 51 | Microsoft::WRL::ComPtr mpVertexShader; 52 | Microsoft::WRL::ComPtr mpPixelShader; 53 | 54 | Microsoft::WRL::ComPtr mpVertexBuffer; 55 | Microsoft::WRL::ComPtr mpIndexBuffer; 56 | Microsoft::WRL::ComPtr mpInputLayout; 57 | 58 | Microsoft::WRL::ComPtr mpStreamOutputBuffer; 59 | 60 | }; 61 | -------------------------------------------------------------------------------- /Project/Part14_Query/Part14_Query.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {b385e57e-92de-47b8-9471-d4ff6f9973c8} 18 | 19 | 20 | {0193bcc9-5708-4391-b9cb-e38fdb14e4e2} 21 | 22 | 23 | 24 | 25 | ソース ファイル\Template 26 | 27 | 28 | ソース ファイル\Template 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | ソース ファイル 35 | 36 | 37 | 38 | 39 | ソース ファイル\Template 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル 46 | 47 | 48 | ソース ファイル 49 | 50 | 51 | 52 | 53 | ソース ファイル\Shader 54 | 55 | 56 | ソース ファイル\Shader 57 | 58 | 59 | ソース ファイル\Shader 60 | 61 | 62 | ソース ファイル\Shader 63 | 64 | 65 | -------------------------------------------------------------------------------- /Project/Part11_StreamOutput/Part11_StreamOutput.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {e535cf72-dedd-4588-9239-658a3f572563} 18 | 19 | 20 | {4ca71424-78e5-410f-ad02-7087fd85904a} 21 | 22 | 23 | 24 | 25 | ソース ファイル 26 | 27 | 28 | ソース ファイル 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | ソース ファイル\Template 35 | 36 | 37 | 38 | 39 | ソース ファイル 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル\Template 46 | 47 | 48 | ソース ファイル\Template 49 | 50 | 51 | 52 | 53 | ソース ファイル\Shader 54 | 55 | 56 | ソース ファイル\Shader 57 | 58 | 59 | ソース ファイル\Shader 60 | 61 | 62 | ソース ファイル\Shader 63 | 64 | 65 | -------------------------------------------------------------------------------- /Project/Part13_Predication/Part13_Predication.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {d3232b62-754e-41f8-8dbb-e8a4e231c962} 18 | 19 | 20 | {1155f960-8e20-4fa5-af0b-c3b05fdf933b} 21 | 22 | 23 | 24 | 25 | ソース ファイル\Template 26 | 27 | 28 | ソース ファイル\Template 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | ソース ファイル 35 | 36 | 37 | 38 | 39 | ソース ファイル\Template 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル 46 | 47 | 48 | ソース ファイル 49 | 50 | 51 | 52 | 53 | ソース ファイル\Shader 54 | 55 | 56 | ソース ファイル\Shader 57 | 58 | 59 | ソース ファイル\Shader 60 | 61 | 62 | ソース ファイル\Shader 63 | 64 | 65 | -------------------------------------------------------------------------------- /Project/Part06_DrawCall/Part06_DrawCall.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {1dbdd666-7b94-47b7-bbfb-74b1b6266cef} 18 | 19 | 20 | {9f315793-639f-4387-bec7-e3668fbc9034} 21 | 22 | 23 | 24 | 25 | ソース ファイル\Template 26 | 27 | 28 | ソース ファイル\Template 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | ソース ファイル 35 | 36 | 37 | 38 | 39 | ソース ファイル\Template 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル 46 | 47 | 48 | ソース ファイル 49 | 50 | 51 | 52 | 53 | ソース ファイル\Shader 54 | 55 | 56 | ソース ファイル\Shader 57 | 58 | 59 | ソース ファイル\Shader 60 | 61 | 62 | ソース ファイル\Shader 63 | 64 | 65 | -------------------------------------------------------------------------------- /Project/Part08_ZBufferAndDepthStencilState/Part08_ZBufferAndDepthStencilState.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {89e0bcfb-8c83-4735-a7ea-150bf0a66d77} 18 | 19 | 20 | {7adcfbfb-1dae-4e85-a220-945edf49c0ad} 21 | 22 | 23 | 24 | 25 | ソース ファイル 26 | 27 | 28 | ソース ファイル 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | ソース ファイル\Template 35 | 36 | 37 | 38 | 39 | ソース ファイル 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル\Template 46 | 47 | 48 | ソース ファイル\Template 49 | 50 | 51 | 52 | 53 | ソース ファイル\Shader 54 | 55 | 56 | ソース ファイル\Shader 57 | 58 | 59 | ソース ファイル\Shader 60 | 61 | 62 | ソース ファイル\Shader 63 | 64 | 65 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /Project/Part04_TypeOfBuffer/Scene.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include "Template/DXSample.h" 24 | 25 | class Scene : public DXSample 26 | { 27 | public: 28 | Scene(UINT width, UINT height, std::wstring name); 29 | 30 | virtual void onInit()override; 31 | virtual void onUpdate()override; 32 | virtual void onRender()override; 33 | virtual void onDestroy()override; 34 | 35 | virtual void onKeyUp(UINT8 key)override; 36 | 37 | private: 38 | void runStackBuffer(); 39 | 40 | void updateTitle(); 41 | void createScreenTexture(); 42 | 43 | private: 44 | enum SHADER_MODE { 45 | eMODE_CONSTANT_BUFFER, 46 | eMODE_STRUCTURED_BUFFER, 47 | eMODE_BYTE_ADDRESS_BUFFER, 48 | eMODE_COUNT, 49 | } mMode = eMODE_CONSTANT_BUFFER; 50 | 51 | Microsoft::WRL::ComPtr mpCSRenderSphereByCB; 52 | Microsoft::WRL::ComPtr mpConstantBuffer; 53 | 54 | Microsoft::WRL::ComPtr mpCSRenderSphereByStructured; 55 | Microsoft::WRL::ComPtr mpStructuredBuffer; 56 | Microsoft::WRL::ComPtr mpStructuredBufferSRV; 57 | 58 | Microsoft::WRL::ComPtr mpCSRenderSphereByByteAddress; 59 | Microsoft::WRL::ComPtr mpByteAddressBuffer; 60 | Microsoft::WRL::ComPtr mpByteAddressBufferSRV; 61 | 62 | Microsoft::WRL::ComPtr mpCBCamera; 63 | 64 | Microsoft::WRL::ComPtr mpScreen; 65 | Microsoft::WRL::ComPtr mpScreenUAV; 66 | }; 67 | -------------------------------------------------------------------------------- /Project/Part10_GeometryShader/Part10_GeometryShader.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {1131d401-a94c-454d-9d4c-c5b7cc513144} 18 | 19 | 20 | {6dc88e52-ff43-48b8-8d83-69a0b4dde642} 21 | 22 | 23 | 24 | 25 | ソース ファイル 26 | 27 | 28 | ソース ファイル 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | ソース ファイル\Template 35 | 36 | 37 | 38 | 39 | ソース ファイル 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル\Template 46 | 47 | 48 | ソース ファイル\Template 49 | 50 | 51 | 52 | 53 | ソース ファイル\Shader 54 | 55 | 56 | ソース ファイル\Shader 57 | 58 | 59 | ソース ファイル\Shader 60 | 61 | 62 | ソース ファイル\Shader 63 | 64 | 65 | ソース ファイル\Shader 66 | 67 | 68 | -------------------------------------------------------------------------------- /Project/Part14_Query/Shader/GeometryShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | struct Input 22 | { 23 | uint id : ID; 24 | }; 25 | 26 | struct GSOutput 27 | { 28 | float4 pos : POSITION; 29 | float4 color : TEXCOORD0; 30 | }; 31 | 32 | static const float4 trianglePos[3] = { 33 | float4(0.f, 0.5f, 0.1f, 1.f), 34 | float4(0.5f, -0.5f, 0.1f, 1.f), 35 | float4(-0.5f, -0.5f, 0.1f, 1.f), 36 | }; 37 | 38 | uint2 random(uint stream, uint sequence) 39 | { 40 | uint2 v = uint2(stream, sequence); 41 | uint s = 0x9E3779B9u; 42 | [unroll] for (int i = 0; i<5; ++i) { 43 | v.x += ((v.y << 4u) + 0xA341316Cu) ^ (v.y + s) ^ ((v.y >> 5u) + 0xC8013EA4u); 44 | v.y += ((v.x << 4u) + 0xAD90777Du) ^ (v.x + s) ^ ((v.x >> 5u) + 0x7E95761Eu); 45 | s += 0x9E3779B9u; 46 | } 47 | return v; 48 | } 49 | 50 | [maxvertexcount(3)] 51 | void main( 52 | point Input input[1], 53 | inout TriangleStream< GSOutput > output 54 | ) 55 | { 56 | uint2 r = random(input[0].id, input[0].id*input[0].id); 57 | float4 offset = 0; 58 | offset.x = r.x / (float)0xffffffff * 2.f - 1; 59 | r = random(r.x, r.y); 60 | offset.y = r.x / (float)0xffffffff * 2.f - 1; 61 | 62 | [unroll] for (uint i = 0; i < 3; i++) { 63 | GSOutput element; 64 | element.pos = trianglePos[i]*0.15f + offset; 65 | 66 | element.color = 1; 67 | r = random(r.x, r.y); 68 | element.color.r = r.x / (float)0xffffffff; 69 | r = random(r.x, r.y); 70 | element.color.g = r.x / (float)0xffffffff; 71 | r = random(r.x, r.y); 72 | element.color.b = r.x / (float)0xffffffff; 73 | 74 | output.Append(element); 75 | } 76 | } -------------------------------------------------------------------------------- /Project/Part11_StreamOutput/Shader/GeometryShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | struct Input 22 | { 23 | uint id : ID; 24 | }; 25 | 26 | struct GSOutput 27 | { 28 | float4 pos : POSITION; 29 | float4 color : TEXCOORD0; 30 | }; 31 | 32 | static const float4 trianglePos[3] = { 33 | float4(0.f, 0.5f, 0.f, 1.f), 34 | float4(0.5f, -0.5f, 0.f, 1.f), 35 | float4(-0.5f, -0.5f, 0.f, 1.f), 36 | }; 37 | 38 | uint2 random(uint stream, uint sequence) 39 | { 40 | uint2 v = uint2(stream, sequence); 41 | uint s = 0x9E3779B9u; 42 | [unroll] for (int i = 0; i<5; ++i) { 43 | v.x += ((v.y << 4u) + 0xA341316Cu) ^ (v.y + s) ^ ((v.y >> 5u) + 0xC8013EA4u); 44 | v.y += ((v.x << 4u) + 0xAD90777Du) ^ (v.x + s) ^ ((v.x >> 5u) + 0x7E95761Eu); 45 | s += 0x9E3779B9u; 46 | } 47 | return v; 48 | } 49 | 50 | [maxvertexcount(3)] 51 | void main( 52 | point Input input[1], 53 | inout TriangleStream< GSOutput > output 54 | ) 55 | { 56 | uint2 r = random(input[0].id, input[0].id*input[0].id); 57 | float4 offset = 0; 58 | offset.x = r.x / (float)0xffffffff * 2.f - 1; 59 | r = random(r.x, r.y); 60 | offset.y = r.x / (float)0xffffffff * 2.f - 1; 61 | 62 | [unroll] for (uint i = 0; i < 3; i++) { 63 | GSOutput element; 64 | element.pos = trianglePos[i]*0.15f + offset; 65 | 66 | element.color = 1; 67 | r = random(r.x, r.y); 68 | element.color.r = r.x / (float)0xffffffff; 69 | r = random(r.x, r.y); 70 | element.color.g = r.x / (float)0xffffffff; 71 | r = random(r.x, r.y); 72 | element.color.b = r.x / (float)0xffffffff; 73 | 74 | output.Append(element); 75 | } 76 | } -------------------------------------------------------------------------------- /Project/Part10_GeometryShader/Scene.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include "Template/DXSample.h" 24 | #include 25 | 26 | class Scene : public DXSample 27 | { 28 | public: 29 | Scene(UINT width, UINT height, std::wstring name); 30 | 31 | virtual void onInit()override; 32 | virtual void onUpdate()override; 33 | virtual void onRender()override; 34 | virtual void onDestroy()override; 35 | 36 | virtual void onKeyUp(UINT8 key)override; 37 | 38 | private: 39 | struct Vertex { 40 | DirectX::SimpleMath::Vector3 pos; 41 | }; 42 | 43 | struct InstancedParam 44 | { 45 | DirectX::SimpleMath::Vector3 offset; 46 | float pad; 47 | DirectX::SimpleMath::Vector4 color; 48 | }; 49 | 50 | private: 51 | void udpateTitle(); 52 | std::vector makeInstanceData()const; 53 | 54 | private: 55 | enum MODE { 56 | eMODE_POINT_TO_TRIANGLE, 57 | eMODE_NO_INPUT_TO_TRIANGLE, 58 | eMODE_COUNT 59 | } mMode = eMODE_POINT_TO_TRIANGLE; 60 | 61 | static const UINT M_INSTANCED_COUNT = 5; 62 | 63 | Microsoft::WRL::ComPtr mpVertexShader; 64 | Microsoft::WRL::ComPtr mpVSDummy; 65 | Microsoft::WRL::ComPtr mpGeometryShader; 66 | Microsoft::WRL::ComPtr mpGeometryShader2; 67 | Microsoft::WRL::ComPtr mpPixelShader; 68 | 69 | Microsoft::WRL::ComPtr mpVertexBuffer; 70 | Microsoft::WRL::ComPtr mpIndexBuffer; 71 | Microsoft::WRL::ComPtr mpInputLayout; 72 | 73 | }; 74 | -------------------------------------------------------------------------------- /Project/Part13_Predication/Shader/GeometryShader.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | struct Input 22 | { 23 | uint id : ID; 24 | }; 25 | 26 | struct GSOutput 27 | { 28 | float4 pos : POSITION; 29 | float4 color : TEXCOORD0; 30 | }; 31 | 32 | static const float4 trianglePos[3] = { 33 | float4(0.f, 0.5f, 0.1f, 1.f), 34 | float4(0.5f, -0.5f, 0.1f, 1.f), 35 | float4(-0.5f, -0.5f, 0.1f, 1.f), 36 | }; 37 | 38 | uint2 random(uint stream, uint sequence) 39 | { 40 | uint2 v = uint2(stream, sequence); 41 | uint s = 0x9E3779B9u; 42 | [unroll] for (int i = 0; i<5; ++i) { 43 | v.x += ((v.y << 4u) + 0xA341316Cu) ^ (v.y + s) ^ ((v.y >> 5u) + 0xC8013EA4u); 44 | v.y += ((v.x << 4u) + 0xAD90777Du) ^ (v.x + s) ^ ((v.x >> 5u) + 0x7E95761Eu); 45 | s += 0x9E3779B9u; 46 | } 47 | return v; 48 | } 49 | 50 | [maxvertexcount(3)] 51 | void main( 52 | point Input input[1], 53 | inout TriangleStream< GSOutput > output 54 | ) 55 | { 56 | uint2 r = random(input[0].id, input[0].id*input[0].id); 57 | float4 offset = 0; 58 | offset.x = r.x / (float)0xffffffff * 2.f - 1; 59 | r = random(r.x, r.y); 60 | offset.y = r.x / (float)0xffffffff * 2.f - 1; 61 | 62 | [unroll] for (uint i = 0; i < 3; i++) { 63 | GSOutput element; 64 | element.pos = trianglePos[i]*0.15f + offset; 65 | 66 | element.color = 1; 67 | r = random(r.x, r.y); 68 | element.color.r = r.x / (float)0xffffffff; 69 | r = random(r.x, r.y); 70 | element.color.g = r.x / (float)0xffffffff; 71 | r = random(r.x, r.y); 72 | element.color.b = r.x / (float)0xffffffff; 73 | 74 | output.Append(element); 75 | } 76 | } -------------------------------------------------------------------------------- /Project/Part09_RasterizerState/Scene.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include "Template/DXSample.h" 24 | #include 25 | 26 | class Scene : public DXSample 27 | { 28 | public: 29 | Scene(UINT width, UINT height, std::wstring name); 30 | 31 | virtual void onInit()override; 32 | virtual void onUpdate()override; 33 | virtual void onRender()override; 34 | virtual void onDestroy()override; 35 | 36 | virtual void onKeyUp(UINT8 key)override; 37 | 38 | private: 39 | struct Vertex { 40 | DirectX::SimpleMath::Vector3 pos; 41 | }; 42 | 43 | struct InstancedParam 44 | { 45 | DirectX::SimpleMath::Vector3 offset; 46 | float pad; 47 | DirectX::SimpleMath::Vector4 color; 48 | }; 49 | void updateTitle(); 50 | std::vector makeInstanceData()const; 51 | 52 | private: 53 | enum MODE { 54 | eMODE_NONE, 55 | eMODE_CULLING, 56 | eMODE_FILL, 57 | eMODE_VIEWPORT, 58 | eMODE_SCISSOR, 59 | eMODE_COUNT 60 | } mMode = eMODE_NONE; 61 | 62 | static const UINT M_INSTANCED_COUNT = 5; 63 | 64 | Microsoft::WRL::ComPtr mpVertexShader; 65 | Microsoft::WRL::ComPtr mpPixelShader; 66 | 67 | Microsoft::WRL::ComPtr mpVertexBuffer; 68 | Microsoft::WRL::ComPtr mpIndexBuffer; 69 | Microsoft::WRL::ComPtr mpInputLayout; 70 | 71 | Microsoft::WRL::ComPtr mpRSCulling; 72 | Microsoft::WRL::ComPtr mpRSFill; 73 | Microsoft::WRL::ComPtr mpRSScissor; 74 | 75 | D3D11_VIEWPORT mDefaultViewport; 76 | }; 77 | -------------------------------------------------------------------------------- /Project/Part17_TiledResource/Scene.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | #include "Template/DXSample.h" 26 | #include 27 | 28 | class Scene : public DXSample 29 | { 30 | public: 31 | Scene(UINT width, UINT height, std::wstring name); 32 | 33 | virtual void onInit()override; 34 | virtual void onUpdate()override; 35 | virtual void onRender()override; 36 | virtual void onDestroy()override; 37 | 38 | virtual void onKeyUp(UINT8 key)override; 39 | 40 | private: 41 | struct TileInfo 42 | { 43 | UINT tileCount; 44 | D3D11_PACKED_MIP_DESC packedMipDesc; 45 | D3D11_TILE_SHAPE tileShape; 46 | UINT subresourceTileCount = 1; 47 | D3D11_SUBRESOURCE_TILING subresourceTiling; 48 | UINT firstSubresourceTile = 0; 49 | }; 50 | 51 | private: 52 | void updateTitle(); 53 | 54 | private: 55 | enum SHADER_MODE { 56 | eMODE_NONE, 57 | eMODE_COUNT, 58 | } mMode = eMODE_NONE; 59 | 60 | Microsoft::WRL::ComPtr mpCSDrawTexture; 61 | Microsoft::WRL::ComPtr mpCBParam; 62 | 63 | Microsoft::WRL::ComPtr mpTilePool; 64 | Microsoft::WRL::ComPtr mpContext2; 65 | 66 | struct TileTexture { 67 | TileInfo mInfo; 68 | Microsoft::WRL::ComPtr mpResource; 69 | Microsoft::WRL::ComPtr mpSRV; 70 | Microsoft::WRL::ComPtr mpUAV; 71 | }; 72 | std::vector mTextures; 73 | TileTexture mTargetTex; 74 | size_t mTargetIndex = 0; 75 | 76 | Microsoft::WRL::ComPtr mpScreen; 77 | Microsoft::WRL::ComPtr mpScreenUAV; 78 | }; 79 | -------------------------------------------------------------------------------- /Project/Part04_TypeOfBuffer/Part04_TypeOfBuffer.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {1df96864-30d7-4cbd-84ee-d54ed675ea9a} 18 | 19 | 20 | {24c04828-e2b6-4595-8566-8ddb50e22be8} 21 | 22 | 23 | 24 | 25 | ソース ファイル\Template 26 | 27 | 28 | ソース ファイル\Template 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | ソース ファイル 35 | 36 | 37 | 38 | 39 | ソース ファイル\Template 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル 46 | 47 | 48 | ソース ファイル 49 | 50 | 51 | 52 | 53 | ソース ファイル\Shader 54 | 55 | 56 | ソース ファイル\Shader 57 | 58 | 59 | ソース ファイル\Shader 60 | 61 | 62 | ソース ファイル\Shader 63 | 64 | 65 | ソース ファイル\Shader 66 | 67 | 68 | 69 | 70 | ソース ファイル\Shader 71 | 72 | 73 | -------------------------------------------------------------------------------- /Project/Part12_Tessellation/Scene.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include "Template/DXSample.h" 24 | #include 25 | 26 | class Scene : public DXSample 27 | { 28 | public: 29 | Scene(UINT width, UINT height, std::wstring name); 30 | 31 | virtual void onInit()override; 32 | virtual void onUpdate()override; 33 | virtual void onRender()override; 34 | virtual void onDestroy()override; 35 | 36 | virtual void onKeyDown(UINT8 key)override; 37 | virtual void onKeyUp(UINT8 key)override; 38 | 39 | private: 40 | void updateTitle(); 41 | 42 | private: 43 | enum MODE { 44 | eMODE_TRIANGLE, 45 | eMODE_QUAD, 46 | eMODE_ISOLINE, 47 | eMODE_POINT_TO_TRIANGLE, 48 | eMODE_COUNT 49 | } mMode = eMODE_TRIANGLE; 50 | 51 | struct HSParam { 52 | float edgeFactor; 53 | float insideFactor; 54 | float pad[2]; 55 | } mHSParam; 56 | 57 | Microsoft::WRL::ComPtr mpHSTriangle; 58 | Microsoft::WRL::ComPtr mpDSTriangle; 59 | 60 | Microsoft::WRL::ComPtr mpHSQuad; 61 | Microsoft::WRL::ComPtr mpDSQuad; 62 | 63 | Microsoft::WRL::ComPtr mpHSIsoline; 64 | Microsoft::WRL::ComPtr mpDSIsoline; 65 | 66 | Microsoft::WRL::ComPtr mpHSPointToTriangle; 67 | Microsoft::WRL::ComPtr mpDSPointToTriangle; 68 | 69 | Microsoft::WRL::ComPtr mpVertexShader; 70 | Microsoft::WRL::ComPtr mpPixelShader; 71 | 72 | Microsoft::WRL::ComPtr mpVertexBuffer; 73 | Microsoft::WRL::ComPtr mpHSParamBuffer; 74 | Microsoft::WRL::ComPtr mpInputLayout; 75 | Microsoft::WRL::ComPtr mpRSWireframe; 76 | }; 77 | -------------------------------------------------------------------------------- /Project/Part07_RenderTargetAndBlendState/Scene.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include "Template/DXSample.h" 24 | #include 25 | 26 | class Scene : public DXSample 27 | { 28 | public: 29 | Scene(UINT width, UINT height, std::wstring name); 30 | 31 | virtual void onInit()override; 32 | virtual void onUpdate()override; 33 | virtual void onRender()override; 34 | virtual void onDestroy()override; 35 | 36 | virtual void onKeyUp(UINT8 key)override; 37 | 38 | private: 39 | struct Vertex { 40 | DirectX::SimpleMath::Vector3 pos; 41 | }; 42 | 43 | struct InstancedParam 44 | { 45 | DirectX::SimpleMath::Vector3 offset; 46 | float pad; 47 | DirectX::SimpleMath::Vector4 color; 48 | }; 49 | std::vector makeInstanceData()const; 50 | 51 | private: 52 | void updateTitle(); 53 | 54 | private: 55 | enum BLEND_MODE { 56 | eBLEND_MODE_SAME_BLEND, 57 | eBLEND_MODE_SEPARATEBLEND, 58 | eBLEND_MODE_COUNT, 59 | } mBlendMode = eBLEND_MODE_SAME_BLEND; 60 | 61 | enum SHOW_RENDER_TARGET { 62 | eSHOW_RT_1, 63 | eSHOW_RT_2, 64 | eSHOW_RT_COUNT, 65 | }mShowRT = eSHOW_RT_1; 66 | static const UINT M_INSTANCED_COUNT = 5; 67 | 68 | Microsoft::WRL::ComPtr mpVertexShader; 69 | Microsoft::WRL::ComPtr mpPixelShader; 70 | 71 | Microsoft::WRL::ComPtr mpVertexBuffer; 72 | Microsoft::WRL::ComPtr mpIndexBuffer; 73 | Microsoft::WRL::ComPtr mpInputLayout; 74 | 75 | Microsoft::WRL::ComPtr mpOffsetBuffer; 76 | Microsoft::WRL::ComPtr mpOffsetBufferSRV; 77 | 78 | Microsoft::WRL::ComPtr mpRenderTarget1; 79 | Microsoft::WRL::ComPtr mpRenderTarget2; 80 | Microsoft::WRL::ComPtr mpRenderTarget1RTV; 81 | Microsoft::WRL::ComPtr mpRenderTarget2RTV; 82 | 83 | Microsoft::WRL::ComPtr mpBlendState; 84 | Microsoft::WRL::ComPtr mpBlendState2; 85 | 86 | }; 87 | -------------------------------------------------------------------------------- /Project/Part08_ZBufferAndDepthStencilState/Scene.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include "Template/DXSample.h" 24 | #include 25 | 26 | class Scene : public DXSample 27 | { 28 | public: 29 | Scene(UINT width, UINT height, std::wstring name); 30 | 31 | virtual void onInit()override; 32 | virtual void onUpdate()override; 33 | virtual void onRender()override; 34 | virtual void onDestroy()override; 35 | 36 | virtual void onKeyUp(UINT8 key)override; 37 | 38 | private: 39 | struct Vertex { 40 | DirectX::SimpleMath::Vector3 pos; 41 | }; 42 | 43 | struct InstancedParam 44 | { 45 | DirectX::SimpleMath::Vector3 offset; 46 | float pad; 47 | DirectX::SimpleMath::Vector4 color; 48 | }; 49 | 50 | void updateTitle(); 51 | std::vector makeInstanceData()const; 52 | 53 | private: 54 | enum MODE { 55 | eMODE_NONE, 56 | eMODE_DEPTH_TEST, 57 | eMODE_STENCIL_TEST, 58 | eMODE_EARLY_Z, 59 | eMODE_COUNT 60 | } mMode = eMODE_NONE; 61 | 62 | static const UINT M_INSTANCED_COUNT = 5; 63 | 64 | Microsoft::WRL::ComPtr mpVertexShader; 65 | Microsoft::WRL::ComPtr mpPixelShader; 66 | Microsoft::WRL::ComPtr mpPSEarlyZ; 67 | 68 | Microsoft::WRL::ComPtr mpVertexBuffer; 69 | Microsoft::WRL::ComPtr mpIndexBuffer; 70 | Microsoft::WRL::ComPtr mpInputLayout; 71 | 72 | Microsoft::WRL::ComPtr mpVSLargeTriangle; 73 | Microsoft::WRL::ComPtr mpLargeTriangleBuffer; 74 | 75 | Microsoft::WRL::ComPtr mpOffsetBuffer; 76 | Microsoft::WRL::ComPtr mpOffsetBufferSRV; 77 | 78 | Microsoft::WRL::ComPtr mpBlendState; 79 | 80 | Microsoft::WRL::ComPtr mpDepthStencil; 81 | Microsoft::WRL::ComPtr mpDepthStencilDSV; 82 | 83 | Microsoft::WRL::ComPtr mpDSDepthTest; 84 | Microsoft::WRL::ComPtr mpDSStencilTest; 85 | 86 | }; 87 | -------------------------------------------------------------------------------- /Project/Template/DXSample.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include "Common.h" 24 | 25 | #include "Win32Application.h" 26 | 27 | class DXSample 28 | { 29 | public: 30 | DXSample(UINT width, UINT height, std::wstring name); 31 | virtual ~DXSample(); 32 | 33 | void init(); 34 | void update(); 35 | void render(); 36 | void destroy(); 37 | void resizeWindow(WPARAM wParam, UINT width, UINT height); 38 | 39 | // Samples override the event handlers to handle specific messages. 40 | virtual void onKeyDown(UINT8 /*key*/) {} 41 | virtual void onKeyUp(UINT8 /*key*/) {} 42 | 43 | // Accessors. 44 | UINT width() const { return this->mWidth; } 45 | UINT height() const { return this->mHeight; } 46 | const WCHAR* title() const { return this->mTitle.c_str(); } 47 | 48 | void parseCommandLineArgs(_In_reads_(argc) WCHAR* argv[], int argc); 49 | 50 | Microsoft::WRL::ComPtr& device() { return this->mpDevice; } 51 | Microsoft::WRL::ComPtr& context() { return this->mpImmediateContext; } 52 | Microsoft::WRL::ComPtr& swapChain() { return this->mpSwapChain; } 53 | 54 | protected: 55 | virtual void onInit() = 0; 56 | virtual void onUpdate() = 0; 57 | virtual void onRender() = 0; 58 | virtual void onDestroy() = 0; 59 | virtual void onResizeWindow(WPARAM wParam, UINT width, UINT height) {} 60 | 61 | void initD3D11(); 62 | 63 | void setCustomWindowText(LPCWSTR text); 64 | 65 | // Viewport dimensions. 66 | UINT mWidth; 67 | UINT mHeight; 68 | float mAspectRatio; 69 | 70 | Microsoft::WRL::ComPtr mpDevice; 71 | Microsoft::WRL::ComPtr mpImmediateContext; 72 | Microsoft::WRL::ComPtr mpSwapChain; 73 | Microsoft::WRL::ComPtr mpBackBuffer; 74 | Microsoft::WRL::ComPtr mpBackBufferRTV; 75 | Microsoft::WRL::ComPtr mpZBuffer; 76 | Microsoft::WRL::ComPtr mpZBufferDSV; 77 | 78 | private: 79 | // Window title. 80 | std::wstring mTitle; 81 | }; 82 | -------------------------------------------------------------------------------- /Project/Part12_Tessellation/Part12_Tessellation.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {7725624b-961c-4b6c-8a22-3ae9247c7055} 18 | 19 | 20 | {f27d899f-8231-48ca-a56a-ae1c389bd899} 21 | 22 | 23 | 24 | 25 | ソース ファイル\Template 26 | 27 | 28 | ソース ファイル\Template 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | ソース ファイル 35 | 36 | 37 | 38 | 39 | ソース ファイル\Template 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル 46 | 47 | 48 | ソース ファイル 49 | 50 | 51 | 52 | 53 | ソース ファイル\Shader 54 | 55 | 56 | ソース ファイル\Shader 57 | 58 | 59 | ソース ファイル\Shader 60 | 61 | 62 | ソース ファイル\Shader 63 | 64 | 65 | ソース ファイル\Shader 66 | 67 | 68 | ソース ファイル\Shader 69 | 70 | 71 | ソース ファイル\Shader 72 | 73 | 74 | ソース ファイル\Shader 75 | 76 | 77 | ソース ファイル\Shader 78 | 79 | 80 | ソース ファイル\Shader 81 | 82 | 83 | -------------------------------------------------------------------------------- /Project/Part16_Texture2/Part16_Texture2.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {b72cb24b-c291-42cf-b182-cd684e3e9738} 18 | 19 | 20 | {c4aa8e93-80c8-49d8-bd55-2b93ac4a80d9} 21 | 22 | 23 | 24 | 25 | ソース ファイル 26 | 27 | 28 | ソース ファイル 29 | 30 | 31 | ソース ファイル\Template 32 | 33 | 34 | ソース ファイル\Template 35 | 36 | 37 | 38 | 39 | ソース ファイル 40 | 41 | 42 | ソース ファイル\Template 43 | 44 | 45 | ソース ファイル\Template 46 | 47 | 48 | ソース ファイル\Template 49 | 50 | 51 | 52 | 53 | ソース ファイル\Shader 54 | 55 | 56 | ソース ファイル\Shader 57 | 58 | 59 | ソース ファイル\Shader 60 | 61 | 62 | ソース ファイル\Shader 63 | 64 | 65 | ソース ファイル\Shader 66 | 67 | 68 | ソース ファイル\Shader 69 | 70 | 71 | ソース ファイル\Shader 72 | 73 | 74 | ソース ファイル\Shader 75 | 76 | 77 | ソース ファイル\Shader 78 | 79 | 80 | ソース ファイル\Shader 81 | 82 | 83 | ソース ファイル\Shader 84 | 85 | 86 | 87 | 88 | ソース ファイル\Shader 89 | 90 | 91 | -------------------------------------------------------------------------------- /Project/Part13_Predication/Scene.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include "Template/DXSample.h" 24 | #include 25 | 26 | class Scene : public DXSample 27 | { 28 | public: 29 | Scene(UINT width, UINT height, std::wstring name); 30 | 31 | virtual void onInit()override; 32 | virtual void onUpdate()override; 33 | virtual void onRender()override; 34 | virtual void onDestroy()override; 35 | 36 | virtual void onKeyUp(UINT8 key)override; 37 | 38 | private: 39 | struct Vertex { 40 | DirectX::SimpleMath::Vector3 pos; 41 | DirectX::SimpleMath::Vector4 color; 42 | }; 43 | 44 | struct CounterType 45 | { 46 | D3D11_COUNTER_TYPE type; 47 | std::string name; 48 | std::string units; 49 | std::string decription; 50 | }; 51 | 52 | union CounterValue { 53 | float f; 54 | UINT16 u16; 55 | UINT32 u32; 56 | UINT64 u64; 57 | 58 | UINT stride(D3D11_COUNTER_TYPE type)const 59 | { 60 | switch (type) { 61 | case D3D11_COUNTER_TYPE_FLOAT32: return sizeof(float); 62 | case D3D11_COUNTER_TYPE_UINT16: return sizeof(UINT16); 63 | case D3D11_COUNTER_TYPE_UINT32: return sizeof(UINT32); 64 | case D3D11_COUNTER_TYPE_UINT64: return sizeof(UINT64); 65 | default: return 0; 66 | } 67 | } 68 | 69 | std::string toString(D3D11_COUNTER_TYPE type)const 70 | { 71 | switch (type) { 72 | case D3D11_COUNTER_TYPE_FLOAT32: return std::to_string(this->f); 73 | case D3D11_COUNTER_TYPE_UINT16: return std::to_string(this->u16); 74 | case D3D11_COUNTER_TYPE_UINT32: return std::to_string(this->u32); 75 | case D3D11_COUNTER_TYPE_UINT64: return std::to_string(this->u64); 76 | default: return "NOT HAVE VALUE"; 77 | } 78 | } 79 | }; 80 | 81 | void renderQuery(); 82 | void renderPredicate(); 83 | 84 | void outputTriangles(UINT count); 85 | void renderTriangles(UINT count); 86 | 87 | private: 88 | enum MODE { 89 | eMODE_QUERY, 90 | eMODE_PREDICATE, 91 | eMODE_COUNT, 92 | } mMode = eMODE_QUERY; 93 | 94 | static const UINT M_STREAM_OUTPUT_COUNT = 100 * 3; 95 | 96 | CounterType mCounterType; 97 | 98 | Microsoft::WRL::ComPtr mpVSStreamOutput; 99 | Microsoft::WRL::ComPtr mpGeometryShader; 100 | 101 | Microsoft::WRL::ComPtr mpVertexShader; 102 | Microsoft::WRL::ComPtr mpPixelShader; 103 | 104 | Microsoft::WRL::ComPtr mpVertexBuffer; 105 | Microsoft::WRL::ComPtr mpInputLayout; 106 | 107 | Microsoft::WRL::ComPtr mpStreamOutputBuffer; 108 | 109 | bool mOnPredicate = true; 110 | Microsoft::WRL::ComPtr mpDSNotDepthTestPass; 111 | 112 | Microsoft::WRL::ComPtr mpQuery; 113 | Microsoft::WRL::ComPtr mpPredicate; 114 | Microsoft::WRL::ComPtr mpCounter; 115 | Microsoft::WRL::ComPtr mpCounter2; 116 | }; 117 | -------------------------------------------------------------------------------- /Project/Part14_Query/Scene.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include "Template/DXSample.h" 24 | #include 25 | 26 | class Scene : public DXSample 27 | { 28 | public: 29 | Scene(UINT width, UINT height, std::wstring name); 30 | 31 | virtual void onInit()override; 32 | virtual void onUpdate()override; 33 | virtual void onRender()override; 34 | virtual void onDestroy()override; 35 | 36 | virtual void onKeyUp(UINT8 key)override; 37 | 38 | private: 39 | struct Vertex { 40 | DirectX::SimpleMath::Vector3 pos; 41 | DirectX::SimpleMath::Vector4 color; 42 | }; 43 | 44 | struct CounterType 45 | { 46 | D3D11_COUNTER_TYPE type; 47 | std::string name; 48 | std::string units; 49 | std::string decription; 50 | }; 51 | 52 | union CounterValue { 53 | float f; 54 | UINT16 u16; 55 | UINT32 u32; 56 | UINT64 u64; 57 | 58 | UINT stride(D3D11_COUNTER_TYPE type)const 59 | { 60 | switch (type) { 61 | case D3D11_COUNTER_TYPE_FLOAT32: return sizeof(float); 62 | case D3D11_COUNTER_TYPE_UINT16: return sizeof(UINT16); 63 | case D3D11_COUNTER_TYPE_UINT32: return sizeof(UINT32); 64 | case D3D11_COUNTER_TYPE_UINT64: return sizeof(UINT64); 65 | default: return 0; 66 | } 67 | } 68 | 69 | std::string toString(D3D11_COUNTER_TYPE type)const 70 | { 71 | switch (type) { 72 | case D3D11_COUNTER_TYPE_FLOAT32: return std::to_string(this->f); 73 | case D3D11_COUNTER_TYPE_UINT16: return std::to_string(this->u16); 74 | case D3D11_COUNTER_TYPE_UINT32: return std::to_string(this->u32); 75 | case D3D11_COUNTER_TYPE_UINT64: return std::to_string(this->u64); 76 | default: return "NOT HAVE VALUE"; 77 | } 78 | } 79 | }; 80 | 81 | private: 82 | void udpateTitle(); 83 | 84 | void renderQuery(); 85 | void renderPredicate(); 86 | 87 | void outputTriangles(UINT count); 88 | void renderTriangles(UINT count); 89 | 90 | private: 91 | enum MODE { 92 | eMODE_QUERY, 93 | eMODE_PREDICATE, 94 | eMODE_COUNT, 95 | } mMode = eMODE_QUERY; 96 | 97 | static const UINT M_STREAM_OUTPUT_COUNT = 100 * 3; 98 | 99 | CounterType mCounterType; 100 | 101 | Microsoft::WRL::ComPtr mpVSStreamOutput; 102 | Microsoft::WRL::ComPtr mpGeometryShader; 103 | 104 | Microsoft::WRL::ComPtr mpVertexShader; 105 | Microsoft::WRL::ComPtr mpPixelShader; 106 | 107 | Microsoft::WRL::ComPtr mpVertexBuffer; 108 | Microsoft::WRL::ComPtr mpInputLayout; 109 | 110 | Microsoft::WRL::ComPtr mpStreamOutputBuffer; 111 | 112 | bool mOnPredicate = true; 113 | Microsoft::WRL::ComPtr mpDSNotDepthTestPass; 114 | 115 | Microsoft::WRL::ComPtr mpQuery; 116 | Microsoft::WRL::ComPtr mpPredicate; 117 | Microsoft::WRL::ComPtr mpCounter; 118 | Microsoft::WRL::ComPtr mpCounter2; 119 | }; 120 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | # DNX 42 | project.lock.json 43 | artifacts/ 44 | 45 | *_i.c 46 | *_p.c 47 | *_i.h 48 | *.ilk 49 | *.meta 50 | *.obj 51 | *.pch 52 | *.pdb 53 | *.pgc 54 | *.pgd 55 | *.rsp 56 | *.sbr 57 | *.tlb 58 | *.tli 59 | *.tlh 60 | *.tmp 61 | *.tmp_proj 62 | *.log 63 | *.vspscc 64 | *.vssscc 65 | .builds 66 | *.pidb 67 | *.svclog 68 | *.scc 69 | 70 | # Chutzpah Test files 71 | _Chutzpah* 72 | 73 | # Visual C++ cache files 74 | ipch/ 75 | *.aps 76 | *.ncb 77 | *.opensdf 78 | *.sdf 79 | *.cachefile 80 | 81 | # Visual Studio profiler 82 | *.psess 83 | *.vsp 84 | *.vspx 85 | 86 | # TFS 2012 Local Workspace 87 | $tf/ 88 | 89 | # Guidance Automation Toolkit 90 | *.gpState 91 | 92 | # ReSharper is a .NET coding add-in 93 | _ReSharper*/ 94 | *.[Rr]e[Ss]harper 95 | *.DotSettings.user 96 | 97 | # JustCode is a .NET coding add-in 98 | .JustCode 99 | 100 | # TeamCity is a build add-in 101 | _TeamCity* 102 | 103 | # DotCover is a Code Coverage Tool 104 | *.dotCover 105 | 106 | # NCrunch 107 | _NCrunch_* 108 | .*crunch*.local.xml 109 | 110 | # MightyMoose 111 | *.mm.* 112 | AutoTest.Net/ 113 | 114 | # Web workbench (sass) 115 | .sass-cache/ 116 | 117 | # Installshield output folder 118 | [Ee]xpress/ 119 | 120 | # DocProject is a documentation generator add-in 121 | DocProject/buildhelp/ 122 | DocProject/Help/*.HxT 123 | DocProject/Help/*.HxC 124 | DocProject/Help/*.hhc 125 | DocProject/Help/*.hhk 126 | DocProject/Help/*.hhp 127 | DocProject/Help/Html2 128 | DocProject/Help/html 129 | 130 | # Click-Once directory 131 | publish/ 132 | 133 | # Publish Web Output 134 | *.[Pp]ublish.xml 135 | *.azurePubxml 136 | ## TODO: Comment the next line if you want to checkin your 137 | ## web deploy settings but do note that will include unencrypted 138 | ## passwords 139 | #*.pubxml 140 | 141 | *.publishproj 142 | 143 | # NuGet Packages 144 | *.nupkg 145 | # The packages folder can be ignored because of Package Restore 146 | **/packages/* 147 | # except build/, which is used as an MSBuild target. 148 | !**/packages/build/ 149 | # Uncomment if necessary however generally it will be regenerated when needed 150 | #!**/packages/repositories.config 151 | 152 | # Windows Azure Build Output 153 | csx/ 154 | *.build.csdef 155 | 156 | # Windows Store app package directory 157 | AppPackages/ 158 | 159 | # Visual Studio cache files 160 | # files ending in .cache can be ignored 161 | *.[Cc]ache 162 | # but keep track of directories ending in .cache 163 | !*.[Cc]ache/ 164 | 165 | # Others 166 | ClientBin/ 167 | [Ss]tyle[Cc]op.* 168 | ~$* 169 | *~ 170 | *.dbmdl 171 | *.dbproj.schemaview 172 | *.pfx 173 | *.publishsettings 174 | node_modules/ 175 | orleans.codegen.cs 176 | 177 | # RIA/Silverlight projects 178 | Generated_Code/ 179 | 180 | # Backup & report files from converting an old project file 181 | # to a newer Visual Studio version. Backup files are not needed, 182 | # because we have git ;-) 183 | _UpgradeReport_Files/ 184 | Backup*/ 185 | UpgradeLog*.XML 186 | UpgradeLog*.htm 187 | 188 | # SQL Server files 189 | *.mdf 190 | *.ldf 191 | 192 | # Business Intelligence projects 193 | *.rdl.data 194 | *.bim.layout 195 | *.bim_*.settings 196 | 197 | # Microsoft Fakes 198 | FakesAssemblies/ 199 | 200 | # Node.js Tools for Visual Studio 201 | .ntvs_analysis.dat 202 | 203 | # Visual Studio 6 build log 204 | *.plg 205 | 206 | # Visual Studio 6 workspace options file 207 | *.opt 208 | 209 | # LightSwitch generated files 210 | GeneratedArtifacts/ 211 | _Pvt_Extensions/ 212 | ModelManifest.xml 213 | *.cso 214 | /Project/Project.VC.db 215 | -------------------------------------------------------------------------------- /Project/Template/Win32Application.cpp: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #include "Win32Application.h" 22 | 23 | HWND Win32Application::sHwnd = nullptr; 24 | 25 | int Win32Application::run(DXSample* pSample, HINSTANCE hInstance, int nCmdShow) 26 | { 27 | CoInitializeEx(NULL, COINIT_MULTITHREADED); 28 | 29 | // Parse the command line parameters 30 | int argc; 31 | LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); 32 | pSample->parseCommandLineArgs(argv, argc); 33 | LocalFree(argv); 34 | 35 | // Initialize the window class. 36 | WNDCLASSEX windowClass = { 0 }; 37 | windowClass.cbSize = sizeof(WNDCLASSEX); 38 | windowClass.style = CS_HREDRAW | CS_VREDRAW; 39 | windowClass.lpfnWndProc = windowProc; 40 | windowClass.hInstance = hInstance; 41 | windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); 42 | windowClass.lpszClassName = L"DXSampleClass"; 43 | RegisterClassEx(&windowClass); 44 | 45 | RECT windowRect = { 0, 0, static_cast(pSample->width()), static_cast(pSample->height()) }; 46 | AdjustWindowRect(&windowRect, WS_OVERLAPPEDWINDOW, FALSE); 47 | 48 | // Create the window and store a handle to it. 49 | sHwnd = CreateWindow( 50 | windowClass.lpszClassName, 51 | pSample->title(), 52 | WS_OVERLAPPEDWINDOW, 53 | CW_USEDEFAULT, 54 | CW_USEDEFAULT, 55 | windowRect.right - windowRect.left, 56 | windowRect.bottom - windowRect.top, 57 | nullptr, // We have no parent window. 58 | nullptr, // We aren't using menus. 59 | hInstance, 60 | pSample); 61 | 62 | // Initialize the sample. OnInit is defined in each child-implementation of DXSample. 63 | pSample->init(); 64 | 65 | ShowWindow(sHwnd, nCmdShow); 66 | 67 | // Main sample loop. 68 | MSG msg = {}; 69 | while (msg.message != WM_QUIT) 70 | { 71 | // Process any messages in the queue. 72 | if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) 73 | { 74 | TranslateMessage(&msg); 75 | DispatchMessage(&msg); 76 | } 77 | } 78 | 79 | pSample->destroy(); 80 | 81 | // Return this part of the WM_QUIT message to Windows. 82 | return static_cast(msg.wParam); 83 | } 84 | 85 | // Main message handler for the sample. 86 | LRESULT CALLBACK Win32Application::windowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 87 | { 88 | DXSample* pSample = reinterpret_cast(GetWindowLongPtr(hWnd, GWLP_USERDATA)); 89 | 90 | switch (message) 91 | { 92 | case WM_CREATE: 93 | { 94 | // Save the DXSample* passed in to CreateWindow. 95 | LPCREATESTRUCT pCreateStruct = reinterpret_cast(lParam); 96 | SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast(pCreateStruct->lpCreateParams)); 97 | } 98 | return 0; 99 | case WM_SIZE: 100 | if (pSample) { 101 | pSample->resizeWindow(wParam, static_cast(LOWORD(lParam)), static_cast(HIWORD(lParam))); 102 | } 103 | return 0; 104 | case WM_KEYDOWN: 105 | if (pSample) 106 | { 107 | pSample->onKeyDown(static_cast(wParam)); 108 | } 109 | if (static_cast(wParam) == VK_ESCAPE) { 110 | SendMessage(hWnd, WM_DESTROY, 0, 0); 111 | } 112 | return 0; 113 | 114 | case WM_KEYUP: 115 | if (pSample) 116 | { 117 | pSample->onKeyUp(static_cast(wParam)); 118 | } 119 | return 0; 120 | 121 | case WM_PAINT: 122 | if (pSample) 123 | { 124 | pSample->update(); 125 | pSample->render(); 126 | } 127 | return 0; 128 | 129 | case WM_DESTROY: 130 | PostQuitMessage(0); 131 | return 0; 132 | } 133 | 134 | // Handle any messages the switch statement didn't. 135 | return DefWindowProc(hWnd, message, wParam, lParam); 136 | } 137 | -------------------------------------------------------------------------------- /Project/Part16_Texture2/Scene.h: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // The MIT License(MIT) 3 | // Copyright(c) 2016 tositeru 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files(the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions : 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR 16 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | //********************************************************* 20 | 21 | #pragma once 22 | 23 | #include "Template/DXSample.h" 24 | #include 25 | 26 | class Scene : public DXSample 27 | { 28 | public: 29 | Scene(UINT width, UINT height, std::wstring name); 30 | 31 | virtual void onInit()override; 32 | virtual void onUpdate()override; 33 | virtual void onRender()override; 34 | virtual void onDestroy()override; 35 | 36 | virtual void onKeyUp(UINT8 key)override; 37 | 38 | private: 39 | struct Texture2D { 40 | Microsoft::WRL::ComPtr mpCSRead; 41 | Microsoft::WRL::ComPtr mpCSWrite; 42 | Microsoft::WRL::ComPtr mpCSReadParam; 43 | Microsoft::WRL::ComPtr mpCSWriteParam; 44 | 45 | Microsoft::WRL::ComPtr mpResource; 46 | Microsoft::WRL::ComPtr mpSRV; 47 | std::vector> mpUAVs; 48 | 49 | }; 50 | 51 | struct MipmapReadParam { 52 | uint32_t mipLevel; 53 | uint32_t isUseSampler; 54 | float pad[2]; 55 | }; 56 | 57 | struct MipmapWriteParam { 58 | DirectX::SimpleMath::Vector4 baseColor; 59 | }; 60 | 61 | struct ArrayReadParam { 62 | uint32_t arrayIndex; 63 | uint32_t isUseSampler; 64 | float pad[2]; 65 | }; 66 | 67 | struct ArrayWriteParam { 68 | DirectX::SimpleMath::Vector4 baseColor; 69 | uint32_t arrayIndex; 70 | float pad[3]; 71 | }; 72 | 73 | struct Cubemap { 74 | Microsoft::WRL::ComPtr mpVSRenderCubemap; 75 | Microsoft::WRL::ComPtr mpGSRenderCubemap; 76 | Microsoft::WRL::ComPtr mpPSRenderCubemap; 77 | 78 | Microsoft::WRL::ComPtr mpCSUseCubemap; 79 | Microsoft::WRL::ComPtr mpCSUseCubemapParam; 80 | 81 | Microsoft::WRL::ComPtr mpResource; 82 | Microsoft::WRL::ComPtr mpSRV; 83 | Microsoft::WRL::ComPtr mpRTV; 84 | 85 | struct CSUseCubemapParam { 86 | DirectX::SimpleMath::Matrix mInvProjection; 87 | DirectX::SimpleMath::Matrix mRotaMatrix; 88 | }mCubemapParam; 89 | DirectX::SimpleMath::Vector3 mRotaParam; 90 | }; 91 | 92 | struct MultiSampling { 93 | Microsoft::WRL::ComPtr mpVSRenderCubemap; 94 | Microsoft::WRL::ComPtr mpGSRenderCubemap; 95 | Microsoft::WRL::ComPtr mpPSRenderCubemap; 96 | 97 | Microsoft::WRL::ComPtr mpResource; 98 | Microsoft::WRL::ComPtr mpRTV; 99 | 100 | Microsoft::WRL::ComPtr mpRasterizerState; 101 | }; 102 | 103 | private: 104 | void initMipmap(); 105 | void runMipmap(); 106 | 107 | void initArray(UINT arrayLength); 108 | void runArray(); 109 | 110 | void initCubemap(); 111 | void runCubemap(); 112 | 113 | void initMultisampling(UINT samplingCount); 114 | void runMultisampling(); 115 | 116 | void updateTitle(); 117 | 118 | private: 119 | enum SHADER_MODE { 120 | eMODE_MIPMAP, 121 | eMODE_ARRAY, 122 | eMODE_CUBEMAP, 123 | eMODE_MULTISAMPLING, 124 | eMODE_COUNT, 125 | } mMode = eMODE_MIPMAP; 126 | 127 | Microsoft::WRL::ComPtr mpCSClearScreen; 128 | 129 | UINT mReadValue = 0; 130 | bool mIsUseSampler = false; 131 | 132 | Texture2D mMipmap; 133 | Texture2D mArray; 134 | Cubemap mCubemap; 135 | MultiSampling mMultiSampling; 136 | 137 | Microsoft::WRL::ComPtr mpImage; 138 | Microsoft::WRL::ComPtr mpImageSRV; 139 | 140 | UINT mSamplerIndex = 0; 141 | std::vector> mpSamplers; 142 | 143 | Microsoft::WRL::ComPtr mpWriteParam; 144 | 145 | Microsoft::WRL::ComPtr mpScreen; 146 | Microsoft::WRL::ComPtr mpScreenUAV; 147 | }; 148 | -------------------------------------------------------------------------------- /Project/Part15_Initialize/Part15_Initialize.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {C16464D7-C1DD-494D-9F43-638A1D43697F} 23 | Win32Proj 24 | Part15_Initialize 25 | 10.0.10586.0 26 | 27 | 28 | 29 | Application 30 | true 31 | v140 32 | Unicode 33 | 34 | 35 | Application 36 | false 37 | v140 38 | true 39 | Unicode 40 | 41 | 42 | Application 43 | true 44 | v140 45 | Unicode 46 | 47 | 48 | Application 49 | false 50 | v140 51 | true 52 | Unicode 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | true 74 | 75 | 76 | true 77 | 78 | 79 | false 80 | 81 | 82 | false 83 | 84 | 85 | 86 | 87 | 88 | Level3 89 | Disabled 90 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 91 | true 92 | 93 | 94 | Windows 95 | true 96 | 97 | 98 | 99 | 100 | 101 | 102 | Level3 103 | Disabled 104 | _DEBUG;_WINDOWS;%(PreprocessorDefinitions) 105 | true 106 | $(SolutionDir);$(SolutionDir)../Microsoft/; 107 | 108 | 109 | Windows 110 | true 111 | 112 | 113 | 114 | 115 | Level3 116 | 117 | 118 | MaxSpeed 119 | true 120 | true 121 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 122 | true 123 | 124 | 125 | Windows 126 | true 127 | true 128 | true 129 | 130 | 131 | 132 | 133 | Level3 134 | 135 | 136 | MaxSpeed 137 | true 138 | true 139 | NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 140 | true 141 | $(SolutionDir);$(SolutionDir)../Microsoft/; 142 | 143 | 144 | Windows 145 | true 146 | true 147 | true 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | --------------------------------------------------------------------------------