Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
EffectPass.cs
Go to the documentation of this file.
1using System;
5
7
8public sealed class EffectPass
9{
11
13
14 internal unsafe ID3DXBaseEffect* pEffect;
15
16 internal unsafe sbyte* _handle;
17
18 internal int _index;
19
20 internal string _name;
21
23
24 internal uint _textureFlags;
25
26 internal unsafe uint* pVertexShaderCode;
27
28 internal unsafe uint* pPixelShaderCode;
29
31
32 public string Name => _name;
33
34 internal unsafe EffectPass(ID3DXBaseEffect* parent, EffectTechnique technique, sbyte* Pass, int index)
35 {
36 _technique = technique;
37 pEffect = parent;
38 _handle = Pass;
39 _index = index;
40 base._002Ector();
41 ID3DXBaseEffect* ptr = pEffect;
42 System.Runtime.CompilerServices.Unsafe.SkipInit(out _D3DXPASS_DESC d3DXPASS_DESC);
43 int num = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, sbyte*, _D3DXPASS_DESC*, int>)(int)(*(uint*)(*(int*)ptr + 24)))((nint)ptr, _handle, &d3DXPASS_DESC);
44 if (num < 0)
45 {
47 }
48 IntPtr ptr2 = (IntPtr)(void*)(int)(*(uint*)(&d3DXPASS_DESC));
50 pVertexShaderCode = (uint*)(int)System.Runtime.CompilerServices.Unsafe.As<_D3DXPASS_DESC, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXPASS_DESC, 8));
51 pPixelShaderCode = (uint*)(int)System.Runtime.CompilerServices.Unsafe.As<_D3DXPASS_DESC, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXPASS_DESC, 12));
52 pAnnotations = new EffectAnnotationCollection(pEffect, _handle, System.Runtime.CompilerServices.Unsafe.As<_D3DXPASS_DESC, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DXPASS_DESC, 4)));
53 }
54
55 internal unsafe void UpdateHandle(ID3DXBaseEffect* parent, sbyte* handle)
56 {
57 pEffect = parent;
60 }
61
62 internal unsafe void EndPass()
63 {
64 bool lockTaken = false;
65 try
66 {
67 Monitor.Enter(Effect.pSyncObject, ref lockTaken);
68 ID3DXEffect* pComPtr = _technique._parent.pComPtr;
69 if (pComPtr != null)
70 {
71 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, int>)(int)(*(uint*)(*(int*)pComPtr + 264)))((nint)pComPtr);
72 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, int>)(int)(*(uint*)(*(int*)pComPtr + 268)))((nint)pComPtr);
73 }
74 }
75 finally
76 {
77 if (lockTaken)
78 {
80 }
81 }
82 }
83
84 public unsafe void Apply()
85 {
86 Effect parent = _technique._parent;
87 IntPtr pComPtr = (IntPtr)parent.pComPtr;
88 Helpers.CheckDisposed(parent, pComPtr);
89 if (parent._currentTechnique != _technique)
90 {
92 }
93 parent.OnApply();
94 ID3DXEffect* pComPtr2 = parent.pComPtr;
95 GraphicsDevice graphicsDevice = parent.GraphicsDevice;
96 EffectPass activePass = graphicsDevice.activePass;
97 int num;
98 if (activePass == this)
99 {
100 num = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, int>)(int)(*(uint*)(*(int*)pComPtr2 + 260)))((nint)pComPtr2);
101 }
102 else
103 {
104 activePass?.EndPass();
105 System.Runtime.CompilerServices.Unsafe.SkipInit(out uint num2);
106 num = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint*, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 252)))((nint)pComPtr2, &num2, 1u);
107 if (num >= 0)
108 {
109 num = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, int>)(int)(*(uint*)(*(int*)pComPtr2 + 256)))((nint)pComPtr2, (uint)_index);
110 if (num >= 0)
111 {
112 graphicsDevice.activePass = this;
113 if (_stateFlags != 0)
114 {
116 }
117 }
118 else
119 {
120 ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, int>)(int)(*(uint*)(*(int*)pComPtr2 + 268)))((nint)pComPtr2);
121 graphicsDevice.activePass = null;
122 }
123 }
124 else
125 {
126 graphicsDevice.activePass = null;
127 }
128 }
129 StateTrackerDevice* pStateTracker = graphicsDevice.pStateTracker;
130 if (((byte*)pStateTracker)[104] != 0)
131 {
132 ((byte*)pStateTracker)[104] = 0;
134 }
135 if (num < 0)
136 {
138 }
139 }
140
141 private void SyncEffectState()
142 {
144 if (graphicsDevice == null)
145 {
147 }
148 if ((_stateFlags & EffectStateFlags.Blend) != 0)
149 {
150 graphicsDevice.ClearBlendState();
151 }
152 if ((_stateFlags & EffectStateFlags.DepthStencil) != 0)
153 {
154 graphicsDevice.ClearDepthStencilState();
155 }
156 if ((_stateFlags & EffectStateFlags.Rasterizer) != 0)
157 {
158 graphicsDevice.ClearRasterizerState();
159 }
160 if ((_stateFlags & EffectStateFlags.AllSamplers) != 0)
161 {
162 int num = 0;
163 do
164 {
165 if (((uint)_stateFlags & (uint)(8 << num)) != 0)
166 {
167 graphicsDevice.SamplerStates.ClearState(num);
168 }
169 num++;
170 }
171 while (num < 16);
172 }
173 if ((_stateFlags & EffectStateFlags.AllVertexSamplers) == 0)
174 {
175 return;
176 }
177 int num2 = 0;
178 do
179 {
180 if (((uint)_stateFlags & (uint)(524288 << num2)) != 0)
181 {
182 graphicsDevice.VertexSamplerStates.ClearState(num2);
183 }
184 num2++;
185 }
186 while (num2 < 4);
187 }
188}
unsafe void UpdateParent(ID3DXBaseEffect *parent, sbyte *handle)
unsafe void UpdateHandle(ID3DXBaseEffect *parent, sbyte *handle)
Definition EffectPass.cs:55
unsafe EffectPass(ID3DXBaseEffect *parent, EffectTechnique technique, sbyte *Pass, int index)
Definition EffectPass.cs:34
EffectAnnotationCollection pAnnotations
Definition EffectPass.cs:10
static Exception GetExceptionFromResult(uint result)
static void CheckDisposed(object obj, IntPtr pComPtr)
Definition Helpers.cs:188
static unsafe? string PtrToStringAnsi(IntPtr ptr)
Definition Marshal.cs:630
static void Exit(object obj)
static void Enter(object obj)