unsafe public void computeD3DPixPackTextures(Synthesiser m_Synthesizer) { int sz = 0; for (int l = 0; l < Globals.cNumLevels /*m_Synthesizer.getAnalyser().nbLevels()*/; l++) { int csz = Synthesiser.bufferSizeFromWindow(bufferrgn(l)); sz = Math.Max(csz, sz); } mD3DPixPackOffsets = new Texture[m_iNbLevels, Globals.cNumCorrectionPasses, 4]; for (int l = 0; l < m_iNbLevels; l++) { Window window = bufferrgn(l); for (int pass = 0; pass < Globals.cNumCorrectionPasses; pass++) { for (int sub = 0; sub < 4; sub++) { // . which quadrant to update ? int ai = (m_Synthesizer.m_SubpassesOrderingTbl[pass % Globals.SYNTH_ORDER_NUM_PASSES][sub][0] + window.left()) & 1; int aj = (m_Synthesizer.m_SubpassesOrderingTbl[pass % Globals.SYNTH_ORDER_NUM_PASSES][sub][1] + window.top()) & 1; Globals.Assert(ai >= 0 && aj >= 0); Vector4 qszs = m_Synthesizer.bufferSize(sz); mD3DPixPackOffsets[l, pass, sub] = new Texture(BRenderDevice.getDevice(), 5, 5, 1, 0, Format.G16R16F, Pool.Managed); GraphicsStream texstream = mD3DPixPackOffsets[l, pass, sub].LockRectangle(0, LockFlags.None); ushort * data = (ushort *)texstream.InternalDataPointer; int rectPitch = 5 * 2; for (int x = 0; x < 5; x++) { for (int y = 0; y < 5; y++) { int ox = x - 2; int oy = y - 2; int fx = (int)Math.Floor((ox + ai) / 2.0f); int fy = (int)Math.Floor((oy + aj) / 2.0f); Vector4 vq = new Vector4( ((float)(fx + (sz >> 1) * ox) + ai * (sz >> 1)) / qszs.X, ((float)(fy + (sz >> 1) * oy) + aj * (sz >> 1)) / qszs.Y, 0, 0); //offs[x + y * 5] = vq; int srcIndex = x * 2 * sizeof(byte) + y * rectPitch; float16 xx = new float16(vq.X); float16 yy = new float16(vq.Y); data[srcIndex] = xx.getInternalDat(); data[srcIndex + 1] = yy.getInternalDat(); } } mD3DPixPackOffsets[l, pass, sub].UnlockRectangle(0); } } } }
public Pos16_Color(float _x, float _y, float _z, int _color) { float16 tmp = new float16(0); tmp.fromFloat(_x); x = tmp.getInternalDat(); tmp.fromFloat(_y); y = tmp.getInternalDat(); tmp.fromFloat(_z); z = tmp.getInternalDat(); w = 0; color = _color; if (Pos16_Color.vertDecl == null) { VertexElement[] elements = new VertexElement[] { new VertexElement(0, 0, DeclarationType.Float16Four, DeclarationMethod.Default, DeclarationUsage.Position, 0), new VertexElement(0, 8, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0), VertexElement.VertexDeclarationEnd, }; Pos16_Color.vertDecl = new VertexDeclaration(BRenderDevice.getDevice(), elements); } }