Hi, currently I'm working on an alternative active picture with some features optimized for my own game, but I encountered several weird issues, I have googled for solution but got nothing, so I think I should ask here directly, for HWA cSurface tutorial, rather than keep groping in blind.

Thanks in advance.

Values:
src: ST_HWA_ROMTEXTURE
pOffset: ST_HWA_RTTEXTURE
pDisplay: ST_HWA_RTTEXTURE
pTransform: ST_HWA_RTTEXTURE
pTransformBitmap: ST_MEMORYWITHDC

The routine is:
1. Check if need offset, if so, pDisplay = src, else pDisplay = pOffset.
2. BlitEx, blit pDisplay to pTransform.
3. Convert Blitted surface to bitmap (for further usage)

Issues:
1. In DX11, debug & release mode works differently, if src needs offset, then nothing is blitted to pTransform in step 2 in release, but it works properly in debug mode.
Have tweaked several optimize options but it does not help.
2. In DX9, BeginRendering/EndRendering is needed, or the created `ST_HWA_RTTEXTURE` will kept last frame's content.
3. In DX9, with BeginRendering/EndRendering, fusion will freeze if src needs offset, breakpoints in DisplayRunObject can still be hit but display will not be updated.

Repo: https://github.com/defisym/OpenFusio...ensions/NeoPic

Code snippets:

OffsetHWA
Code:
inline bool OffsetHWA(LPSURFACE Src, LPSURFACE Des, int X, int Y, bool Wrap = true) {
	if (X == 0 && Y == 0) {
		return false;
	}

	Des->BeginRendering(TRUE, 0);

	POINT hotSpot = { 0,0 };
	
	auto width = Src->GetWidth();
	auto height = Src->GetHeight();
	
	Src->BlitEx(*Des, (float)X, (float)Y,
		1.0, 1.0, 0, 0,
		width, height, &hotSpot, (float)0,
		BMODE_OPAQUE,
		BOP_COPY);

	//Src->Blit(*Des, X, Y);

	if (Wrap) {
		int XWrap = X > 0 ? X - width : X + width;
		int YWrap = Y > 0 ? Y - height : Y + height;

		Src->BlitEx(*Des, (float)X, (float)YWrap,
			1.0, 1.0, 0, 0,
			width, height, &hotSpot, (float)0,
			BMODE_OPAQUE,
			BOP_COPY);
		Src->BlitEx(*Des, (float)XWrap, (float)Y,
			1.0, 1.0, 0, 0,
			width, height, &hotSpot, (float)0,
			BMODE_OPAQUE,
			BOP_COPY);
		Src->BlitEx(*Des, (float)XWrap, (float)YWrap,
			1.0, 1.0, 0, 0,
			width, height, &hotSpot, (float)0,
			BMODE_OPAQUE,
			BOP_COPY);

		//Src->Blit(*Des, X, YWrap);
		//Src->Blit(*Des, XWrap, Y);
		//Src->Blit(*Des, XWrap, YWrap);
	}

	Des->EndRendering();

	return true;
}
BlitEx routine
Code:
	auto ds = pDisplay->GetRenderTargetSurface();
	pTransform->BeginRendering(TRUE, 0);

	blitResult = ds->BlitEx(*pTransform
		, rdPtr->hotSpot.x * abs(rdPtr->zoomScale.XScale), rdPtr->hotSpot.y * abs(rdPtr->zoomScale.YScale)
		, abs(rdPtr->zoomScale.XScale), abs(rdPtr->zoomScale.YScale), 0, 0
		, rdPtr->src->GetWidth(), rdPtr->src->GetHeight(), &rdPtr->hotSpot, (float)rdPtr->angle
		, (rdPtr->rs.rsEffect & EFFECTFLAG_TRANSPARENT) ? BMODE_TRANSP : BMODE_OPAQUE
		, BlitOp(rdPtr->rs.rsEffect & EFFECT_MASK)
		, rdPtr->rs.rsEffectParam, flags);
	
	pTransform->EndRendering();
	pDisplay->ReleaseRenderTargetSurface(ds);