Add initial D2D1ContouredLayersRunner implementation
このコミットが含まれているのは:
1 親
162b46ed41
コミット
0deddde903
5ファイル変更
+95
-5
検索条件に一致するファイルはありません
@@ -18,6 +18,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Services\IAnalyticsService.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Shaders\ID2D1ShaderRunner.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Shaders\D2D1ShaderRunner{T}.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Shaders\Runners\D2D1ContouredLayersRunner.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Shaders\Runners\ContouredLayersRunner.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\MainViewModel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)ViewModels\ShaderRunnerViewModel.cs" />
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
using System.IO;
|
||||
using CommunityToolkit.Diagnostics;
|
||||
using ComputeSharp.D2D1;
|
||||
using ComputeSharp.D2D1.Interop;
|
||||
using ComputeSharp.D2D1.Uwp;
|
||||
using ComputeSharp.SwapChain.Shaders.D2D1;
|
||||
#if WINDOWS_UWP
|
||||
using Microsoft.Graphics.Canvas;
|
||||
using Microsoft.Graphics.Canvas.UI.Xaml;
|
||||
#else
|
||||
using ComputeSharp.WinUI;
|
||||
#endif
|
||||
using Windows.ApplicationModel;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace ComputeSharp.SwapChain.Core.Shaders.Runners;
|
||||
|
||||
/// <summary>
|
||||
/// A specialized <see cref="ID2D1ShaderRunner"/> for <see cref="ContouredLayers"/>.
|
||||
/// </summary>
|
||||
public sealed class D2D1ContouredLayersRunner : ID2D1ShaderRunner
|
||||
{
|
||||
/// <summary>
|
||||
/// The reusable <see cref="PixelShaderEffect{T}"/> instance to use to render frames.
|
||||
/// </summary>
|
||||
private PixelShaderEffect<ContouredLayers>? pixelShaderEffect;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public unsafe void Execute(ICanvasAnimatedControl sender, CanvasAnimatedDrawEventArgs args)
|
||||
{
|
||||
if (this.pixelShaderEffect is null)
|
||||
{
|
||||
D2D1ResourceTextureManager resourceTextureManager;
|
||||
|
||||
string filename = Path.Combine(Package.Current.InstalledLocation.Path, "Assets", "Textures", "RustyMetal.1024x1024rgba32");
|
||||
|
||||
// Open a file to read from the file (we're doing synchronous IO here by design, doesn't really matter)
|
||||
using (FileStream fileStream = new(filename, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
byte[] pixelData = new byte[(int)fileStream.Length];
|
||||
int totalBytesRead = 0;
|
||||
|
||||
// Read the raw image data
|
||||
while (totalBytesRead < pixelData.Length)
|
||||
{
|
||||
int bytesRead = fileStream.Read(pixelData, 0, pixelData.Length);
|
||||
|
||||
Guard.IsGreaterThan(bytesRead, 0);
|
||||
|
||||
totalBytesRead += bytesRead;
|
||||
}
|
||||
|
||||
// Create the resource texture manager to use in the shader
|
||||
resourceTextureManager = new D2D1ResourceTextureManager(
|
||||
extents: stackalloc uint[] { 1024, 1024 },
|
||||
bufferPrecision: D2D1BufferPrecision.UInt8Normalized,
|
||||
channelDepth: D2D1ChannelDepth.Four,
|
||||
filter: D2D1Filter.MinMagMipLinear,
|
||||
extendModes: stackalloc D2D1ExtendMode[] { D2D1ExtendMode.Mirror, D2D1ExtendMode.Mirror },
|
||||
data: pixelData,
|
||||
strides: stackalloc uint[] { (uint)(1024 * sizeof(Bgra32)) });
|
||||
}
|
||||
|
||||
// Create the new pixel shader effect
|
||||
this.pixelShaderEffect = new PixelShaderEffect<ContouredLayers>() { ResourceTextureManagers = { [0] = resourceTextureManager } };
|
||||
}
|
||||
|
||||
int widthInPixels = sender.ConvertDipsToPixels((float)sender.Size.Width, CanvasDpiRounding.Round);
|
||||
int heightInPixels = sender.ConvertDipsToPixels((float)sender.Size.Height, CanvasDpiRounding.Round);
|
||||
|
||||
// Set the constant buffer
|
||||
this.pixelShaderEffect.ConstantBuffer = new ContouredLayers((float)args.Timing.TotalTime.TotalSeconds, new int2(widthInPixels, heightInPixels));
|
||||
|
||||
// Draw the shader
|
||||
args.DrawingSession.DrawImage(this.pixelShaderEffect);
|
||||
}
|
||||
}
|
||||
@@ -135,10 +135,7 @@ public sealed partial class MainViewModel : ObservableObject
|
||||
typeof(TriangleGridContouring),
|
||||
new ShaderRunner<TriangleGridContouring>(static time => new((float)time.TotalSeconds)),
|
||||
new D2D1ShaderRunner<SwapChain.Shaders.D2D1.TriangleGridContouring>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height)))),
|
||||
new(
|
||||
typeof(ContouredLayers),
|
||||
new ContouredLayersRunner(),
|
||||
new D2D1ShaderRunner<SwapChain.Shaders.D2D1.HelloWorld>(static (time, width, height) => new((float)time.TotalSeconds, new int2(width, height)))),
|
||||
new(typeof(ContouredLayers), new ContouredLayersRunner(), new D2D1ContouredLayersRunner()),
|
||||
new(
|
||||
typeof(TerracedHills),
|
||||
new ShaderRunner<TerracedHills>(static time => new((float)time.TotalSeconds)),
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
�|e��zg��sd��jW��v`��yg��o���t���t���t���t���w�������v��{b��~g���{������|i���w�������������������u�uJ<�rE=��lb�����滋��拶��坤��鉄��禅��抄��脳��直��牲��痕��根��尚��懇��尻��供������������������|c��fM��L@��IE��e[���}�儻��糧��决��領��氾��蒜��澱��疏��疎��模��佰��冪��量��篤��西��庚����������申��斌��癖��差��������������pp��df��QQ��nk��|{�����禅��汁��堆��耐��盃��盤��婦��夫��拝��別��焼��歓��詐��転��房��啣��擣��妣����u�����繕�����潅��使��篠��舵��琳��謡��排��返��瓶��飯��噸��縞��限��俺��袈��集��反��表��兩��敍��楡��售����y�即��濾��崟��鼎���{a��sV���y�廣��悴��甞��甕��咾����m��|f�眠��喘��兵��族��単��前��蒔��������x���i��bO��sa��p\��_K��\H��ZE��lU���p���~���|��nW��]J��C2��;-��L9��\C�����匱��冂��冥����������苅��右��葵��況��限��業��絞��固��最��慶�����Ⅳ�����鬼��叱��艮��������y���e��|Y��|V��{X���i���|���|���������������������������������Б�����ぅ������灰��⑥��������ア������▽��恩��該��柑�����Λ�������゛����������┫��或��価��雲��ゴ�����慧��哉��浬������┯�馨��皇��伽������┓��������������������閏��街��憾�������ヾ����該��飴�����Т������┿�Σ��Π��゛��П��ク������Τ��Т��Т�����甘��宰��縮��析��糠��誼��蛎���Ⅶ�������Р�����げ���粟��粟�����餌��鈎��紅�杏��極��������ゼ��ゼ��Ш�����し��ゲ�����Ⅳ������������暗�������憩��四��劃��何�����景��耕��廓��按��叡��掬��嬰��曲��粛��荏�����Ⅵ��噂�������������ギ����������ケ��Т�����Ⅵ��ゴ�������������������������栄��∈���������洩� ̄��┯�����┯�����┠�����ご��Χ��潅��粟���タ����y���l~�����科���孜��罫�����巾��却��歌��穫��却����o��������㍗�����継��継�ー��⊇��た��た��Э������缶��枯����������J���慕��茶��窃��売�ヌ�����ナ��‘��E���蝉�η�����と���嶋��着����F��ι���鯛�…���巣��大�����������淳��醤��淳��楯��尺�ー��┥���������������������㌢�����������庵��携�╂�����せ������曲��夏��暁�Ь��Ь��╂��た��������┰��ぞ��ぞ�����Э��������┳����������������������������������yr��gar�����Ι�����Ф��┳��ざ������������鞍��果��������}���|��������Щ�����し����������������kfq�vLT��O\��IP��QS��wt��������※��������������◆��Й�����き���������������▲��▽����墾�������mZ��jT��t_��me��������������������������������ク������������┣�����〓���������������������urz����������ぐ��0��ゲ��ゲ��1��く��く��`��`��������������↑�������������������t��ti�����!����������}������ザ����������〓��〓��Ξ��┛�渦��乙��渥��貝��貝��感��蔚��������2���じ�����Ⅹ�ゴ��3���Ц��嚇����l���、��グ���Ш��������~����掲�����ズ��7��Щ�����8�ゴ�������������┰���~���q���`{��x���~���������������������������~��������Ъ���������{���{������������∋�u���j������������ゞ��^���暗��曳��吉�ヾ���������������v���x���}����┿��㍉��������Щ����Ш�����������������������、�����������_��し��Ⅸ�����������粟�����Ω����┿�������������������������������←���������hcr�p]i�Z?J��am��iu����������〓��Υ��ヾ���������|���������������������������������������〆��ー��巾�����缶�w���w��������oq��__��b^��kj�����き���Ⅳ�����p���|������}���z���}���z����������������す��┰��せ��位�������������������������ng��[Y��NE��^O��dT��h^��d_��^Q��te�������������ザ���М�Ю�����╂��、��{������}���v���|��������������o������������������������������������{�������������z���z���u���t���v���v��������╂�����々�|���y���z����ー�~���`u��ky��x�����������Я��タ��ぞ��タ�����γ�����u���{���{���}�������������㍗�����艦��禍��������������������x���jx�������Ъ��������������������q����㌦�}���r���j���r���|�������t���nェ�n���u�������v���Vb�m���}��q���y⊃�{�������а�y����慰��������慰��㏄��為��駅��芹��頚��芹��降�寏��吸��頚��頚��細��杓��尉��閑�t���d���k���z�������~���|��������������{��v���u���q���i���s���n���s���o���h���g���n���n���m���r���{���x����������㎏��苛��閑�{���鋭��益��悦��呉��禁�ł�{x��vfx��������������I��������������m���n���x���{���o���i���g���t��~���y���z��������∥��η�ゥ��ĵ����ĵ��������v���e���\x��b}��Vt��Ii��b���z���t���k���l���m���p���o���m���p���o���f���g��n���m���s���z」�_o��~�������~���t���~����β�����������位��均����~���v���k���oュ�k���l���p���l���p���j���i���k���k���m���o���i���k���e���`���g���b���b���k���i���]���P��S���U���V���P���H{��3b��+R{�+Ny�&Kv��{d��|m��o^��dP��q[��}l���t���q���u���w���x���~���|���s��sZ��t[���|�������m���z�����察�����������~j��WI�uMC�����澄����������宵��星��廠��森��顛��顛��得��彰��鮫��昆��孝��懇��磁��������������������n��wb��YM��UQ��h_��~t�発��肪��緑��癖��特��督��真��十��請��麺��力��様��領��覇��松��魂����������曽��湾��波��戎��況��迂�������lb��pn��WS��]U��ur�����担��青��史��噸��殆��番��盤��便��苫��栃��消��蚕��精��鉄��的��������r���p���a��{e�鉢��覗��澱��品��柁��組��菟��没��不��屯��勃��没��蕃��池��疑��現��騎��燦��脳��添��瞳��殄��拂��愎��垉��峪��拈��由��掠���x_��_F��x_�椄��霸��棆��洌��箚��洌����|�����乃��暴��半��塀��椋��困��������v��mV��_G���v������jO��Z>��`H��oV��w^���n��rX��dK��P8��H4��A0��XH���y�勵��添��滅��直�����巻��鍬�����������再��再��最��最��使��再��何��⑲��蔚��杭��住��岨��������~���r��}b��tY��hT��kY���y�����������������������������������������������Ε��⑦��������������������厩��興��擬�����ガ���?行の続きは省略
|
||||
��B��C��h<��}R���U���U��~Q���a���~�但������尿��法����~���`���b�����堂��自��皐��昏��械��������|���l���c���o���u���s���l��{V��vU��P1��[>��U:��S9��Q7��oW���t��������������y���m�������������������~���{���}���������������u��zh�m7)�s7*�~@4�t8+�k3$��K@��{q��XL�~JB�~MA��`O��lZ��fY��k_��l_��P@��XH�g1�s=)��eQ��jR��{d���r��yg��M=�g0#�j0%�v;-��XK��sf��uh�{H<�uA5�wHA��sh������z��{n��I;��E8��3#�~2(�o.$�b71�~fc�����哀�����������������⑪��査��換��⑱����������������Β������������������あ�����������������▲���0�Η�������������◆����������Λ��酸��臣�������������И��������y~��������������晃��算��逝��狭������������������bk~�����┣�������������3����������飴��Ⅲ��П���������┤������こ�ガ�����ケ�����:�����������Ф����姥��ク���┝��������蟻��垣��化��コ�����゛��↑��ぐ�����款������┷��Ц����゛��形��虻�����Р�����┣�������������������ゼ�Ⅳ�����Σ�����{���|����せ������������Σ�����〓������Ь����������������↓������┥�ぐ��Р��������┳��云�����ゴ���ズ���������ズ��ズ�さ��У��Υ��Ⅵ�����┣���������nt��sy��|�����������������������������Ν�������セ�街��▽��������������������ァ������~z��~����������イ��⑬�������������ぇ��Κ����� ������c\\�i][���������������|�����抗������������������������������岡��徽��鴎��些��姦�����Α��Β��督��申��桶��算��Е�����②�����徽������哀��絵��貝��姦��卯��凱�����⑧�����曽��胆����������|s������������盛��農��拘��沖��昇��醜��醜��疹��誠��差�������������辞��轡��記��������:��������烏��В������������迂��攻��┘�����Α������Γ��珊��攻��室��請��幻��葦��胸��鎖��玄��構��減��沙��瑳��換�����ぃ��崖��鬼����������橋��慨��碓��憶��査��袈��┘��⑮��裟��讃��失�����戯��詐��鎖��構���0�胸���������◆�����Ε��旭�����Е�����|���hl������:����������������幻�����������������か��������沙��従��幻�����狭��⑰����������0�����患��犠��М����������������������������������└���������������zz�����������������繰��鴎�����オ������x|������~�������け�������������������������������������;�□�����誓��係��干��悉��崖��⑬��Ж���������������������ォ�����������������※������┏�����������������������┣����⑲��⑲������|����������������Ф��^������Т��Τ��`������Т����ケ���け��Т��┳����雲������Ⅱ��ぐ���������Р��┳�^����������������コ�:��������※��エ���Τ������������hq������┣��Ο��z~��`ey�nw��v��mv��PZl�}������������������������������z���v���eq��w����「��ジ������シ��4����������ぐ�;��������������pv��y~�����������������������ぐ�������������Т��Σ�������������������������������������������������������������ywz���������~������{wz��������������qm�y[W��gd��YR��]N��S@��XJ�{6%��</��>/��A.��TB��YI��SE��VF��VA��ZE��`J��mX��\I��VA��W@��og����������く��゜������������゜�������������Р�����┳������Р��������������������vw��sw�x��}���{���z���T[i�y~�����������゛��´������������~���rw�������ぐ��´��Р��`��ゴ��������������ll�~RK��SK��c`��������������´��Т�������������������������~��������運��嘉��庵��看��嘉��嚇�����������_�w���y���qu��bhy�ks��t}��w�������������1��������け��v���r{�������������������サ���������{�����������������������������������������������������u~�����������������������������������く�����Р��↓����������������������������������_��������������Χ��Х������������ズ���������3��������������ヽ�����������������y��{�������������������������������|����Ρ��������Τ����〓������}����������������`�▼�����������゛�━��Ι����������������憶��ウ������、��������Ζ��イ��Ζ��⑬��������Γ��ぁ���\:��P6��K7��@+��A,��VB��]O��WG��A6�{;2��N@��t`���p���u��_F��rW���r���k��nS��qU��\B��\B��w_���z���d��vZ��w\���k�������������箱��但���������������n��RE�qA?�rFI�wKO�vJN�pDG�i:9�h96�qC=��mc���������此��抜��標��廼��調��昆��小��燃��潮��詮��織��彫��蓑��菱������彫��摘��稔��吻��勝����|�����鄭�������{q�tMJ�d<?�h>G�lBH�`8:�c;<�kBE�kAB�e:9�h=<�b8<�^5=�c7B�oAJ�n>I�l=K�k=J�e57�D6��}c��`��|b��zb���j������������������t��eP��G4��WF��cT��aK��ZI��F7��D1��o[�����州��秋��職��召��召��畝��贈��任����|�{J6�d4%�nA9�`40�d59�m<?�l@C�j>A�j9<�l58�q35��@@��EA��?>�y52�v.&�u-!�w1'�q/,�l,+�k-,�j.+�o42�q30�r0.�{2/��PO��IA��RA��B+��;+��;3�{5-�u5.�o/&�|.$��9*��@%��c=��f;��Z3��<��$ | ||||