diff -r 267dbc0bb8a4 modules/graphics/src/main/java/com/sun/prism/d3d/D3DContext.java --- a/modules/graphics/src/main/java/com/sun/prism/d3d/D3DContext.java Mon Nov 18 15:48:45 2013 -0800 +++ b/modules/graphics/src/main/java/com/sun/prism/d3d/D3DContext.java Wed Nov 20 17:41:39 2013 -0800 @@ -186,13 +186,17 @@ return res == D3D_OK; } + private static boolean renderTargetChanged[] = new boolean[1]; @Override protected State updateRenderTarget(RenderTarget target, NGCamera camera, boolean depthTest) { long resourceHandle = ((D3DRenderTarget)target).getResourceHandle(); - int res = nSetRenderTarget(pContext, resourceHandle, depthTest, target.isAntiAliasing()); + renderTargetChanged[0] = false; + int res = nSetRenderTarget(pContext, resourceHandle, depthTest, target.isAntiAliasing(), renderTargetChanged); validate(res); - resetLastClip(state); + if (renderTargetChanged[0]) { + resetLastClip(state); + } this.camera = camera; targetWidth = target.getPhysicalWidth(); @@ -334,7 +338,7 @@ * if needed, of the same format as the render target. The depth test state * is handled elsewhere. */ - private static native int nSetRenderTarget(long pContext, long pDest, boolean depthBuffer, boolean msaa); + private static native int nSetRenderTarget(long pContext, long pDest, boolean depthBuffer, boolean msaa, boolean renderTargetChanged[]); private static native int nSetTexture(long pContext, long pTex, int texUnit, boolean linear, int wrapMode); private static native int nResetTransform(long pContext); diff -r 267dbc0bb8a4 modules/graphics/src/main/native-prism-d3d/D3DContext.cc --- a/modules/graphics/src/main/native-prism-d3d/D3DContext.cc Mon Nov 18 15:48:45 2013 -0800 +++ b/modules/graphics/src/main/native-prism-d3d/D3DContext.cc Wed Nov 20 17:41:39 2013 -0800 @@ -864,19 +864,20 @@ HRESULT D3DContext::SetRenderTarget(IDirect3DSurface9 *pSurface, IDirect3DSurface9 **ppTargetDepthSurface, - BOOL depthBuffer, BOOL msaa) + BOOL depthBuffer, BOOL msaa, BOOL &renderTargetChanged) { TraceLn1(NWT_TRACE_INFO, "D3DContext::SetRenderTarget: pSurface=0x%x", pSurface); + renderTargetChanged = false; + RETURN_STATUS_IF_NULL(pd3dDevice, E_FAIL); RETURN_STATUS_IF_NULL(pSurface, E_FAIL); HRESULT res; D3DSURFACE_DESC descNew; IDirect3DSurface9 *pCurrentTarget; - bool renderTargetChanged = false; pSurface->GetDesc(&descNew); diff -r 267dbc0bb8a4 modules/graphics/src/main/native-prism-d3d/D3DContext.h --- a/modules/graphics/src/main/native-prism-d3d/D3DContext.h Mon Nov 18 15:48:45 2013 -0800 +++ b/modules/graphics/src/main/native-prism-d3d/D3DContext.h Wed Nov 20 17:41:39 2013 -0800 @@ -143,7 +143,7 @@ D3DPOOL getResourcePool() { return defaulResourcePool; } - HRESULT SetRenderTarget(IDirect3DSurface9 *pSurface, IDirect3DSurface9 **ppTargetDepthSurface, BOOL depthBuffer, BOOL msaa); + HRESULT SetRenderTarget(IDirect3DSurface9 *pSurface, IDirect3DSurface9 **ppTargetDepthSurface, BOOL depthBuffer, BOOL msaa, BOOL &renderTargetChanged); HRESULT SetCameraPosition(jdouble camPosX, jdouble camPosY, jdouble camPosZ); HRESULT SetProjViewMatrix(BOOL isOrtho, jdouble m00, jdouble m01, jdouble m02, jdouble m03, diff -r 267dbc0bb8a4 modules/graphics/src/main/native-prism-d3d/D3DGraphics.cc --- a/modules/graphics/src/main/native-prism-d3d/D3DGraphics.cc Mon Nov 18 15:48:45 2013 -0800 +++ b/modules/graphics/src/main/native-prism-d3d/D3DGraphics.cc Wed Nov 20 17:41:39 2013 -0800 @@ -392,7 +392,8 @@ * Method: nSetRenderTarget */ JNIEXPORT jint JNICALL Java_com_sun_prism_d3d_D3DContext_nSetRenderTarget - (JNIEnv *, jclass, jlong ctx, jlong targetRes, jboolean depthBuffer, jboolean msaa) + (JNIEnv *env, jclass, jlong ctx, jlong targetRes, + jboolean depthBuffer, jboolean msaa, jbooleanArray renderTargetSetArray) { D3DContext *pCtx = (D3DContext*)jlong_to_ptr(ctx); RETURN_STATUS_IF_NULL(pCtx, E_FAIL); @@ -405,7 +406,12 @@ IDirect3DSurface9 *pDepthBuffer = pRes->GetDepthSurface(); - HRESULT res = pCtx->SetRenderTarget(pRenderTarget, &pDepthBuffer, depthBuffer, msaa); + BOOL renderTargetChanged = false; + HRESULT res = pCtx->SetRenderTarget(pRenderTarget, &pDepthBuffer, + depthBuffer, msaa, renderTargetChanged); + jboolean renderTargetSet[1] = { renderTargetChanged ? JNI_TRUE : JNI_FALSE }; + env->SetBooleanArrayRegion(renderTargetSetArray, 0, 1, renderTargetSet); + pRes->SetDepthSurface(pDepthBuffer); return res; }