2362N/A * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * This table contains the standard blending rules (or Porter-Duff compositing 0N/A * factors) used in SetRenderState(), indexed by the rule constants from the 0N/A * AlphaComposite class. 430N/A// the following methods are copies of the AffineTransform's class 430N/A// corresponding methods, with these changes to the indexes: 430N/A "D3DContext::ReleaseContextResources: pd3dDevice = 0x%x",
430N/A // dispose shader lists 430N/A "~D3DContext: pd3dDevice=0x%x, pd3dObject =0x%x",
0N/A // disable some of the unneeded and costly d3d functionality 430N/A // set the default texture addressing mode 430N/A // REMIND: check supported filters with 430N/A // IDirect3D9::CheckDeviceFormat with D3DUSAGE_QUERY_FILTER 0N/A // these states never change 0N/A // init the array of latest textures 430N/A // we can live without the cache 430N/A // we can live without the cache 430N/A // this is allowed to fail, do not propagate the error 430N/A "D3DContext::InitDevice: sync query not available");
430N/A "D3DContext::InitDevice: " 430N/A "error creating sync surface");
430N/A "D3DContext::InitDefice: successfully initialized device %d",
430N/A // nothing to be done here, wait for D3DERR_DEVICENOTRESET 430N/A // some unexpected error 430N/A "unknown error %x from TestCooperativeLevel");
430N/A // reset to the current display mode if we're windowed, 430N/A // otherwise to the display mode we were in when the device 430N/A // this is needed so that we can find the stencil buffer format 430N/A // do not set device window in the windowed mode, we use additional 430N/A // swap chains for rendering, the default chain is not used. otherwise 430N/A // our scratch focus window will be made visible 430N/A // mode. It may either be set to the default focus window (when there are 430N/A // no more devices in fs mode), or to fs window for another device 430N/A // in fs mode. See D3DPipelineManager::GetCurrentFocusWindow. 430N/A " focus window changed, need to recreate the device");
430N/A // if fs -> windowed, first exit fs, then recreate, otherwise 430N/A // the screen might be left in a different display mode 430N/A " exiting full-screen mode, reset the device");
430N/A "cound not reset the device");
430N/A // note that here we should release all device resources, not only 430N/A // thos in the default pool since the device is released 430N/A "D3DContext::ConfigureContext: cound not reset the device");
430N/A "D3DContext::ConfigureContext: successfully reset device: %d",
430N/A "D3DContext::ConfigureContext: failed to get caps");
430N/A // not preserving fpu control word could cause issues (4860749) 430N/A "[V] dwBehaviorFlags=D3DCREATE_FPU_PRESERVE|");
430N/A "D3DCREATE_HARDWARE_VERTEXPROCESSING");
430N/A "D3DCREATE_SOFTWARE_VERTEXPROCESSING");
430N/A // Handling focus changes by ourselves proved to be problematic, 430N/A // so we're reverting back to D3D handling 430N/A // dwBehaviorFlags |= D3DCREATE_NOWINDOWCHANGES; 430N/A "D3DContext::ConfigureContext: error creating d3d device");
430N/A "D3DContext::ConfigureContext: successfully created device: %d",
430N/A // during the creation of the device d3d modifies this field, we reset 430N/A "D3DContext::SaveState: existing state block!");
430N/A "D3DContext::SaveState: failed to create state block");
430N/A "D3DContext::RestoreState: failed to restore state");
430N/A "D3DContext::RestoreState: empty state block!");
430N/A " current stencil buffer is not compatible with new Render Target");
430N/A "D3DContext::SetRenderTarget: pSurface=0x%x",
430N/A "error setting render target");
430N/A // we set the transform even if the render target didn't change; 430N/A // this is because in some cases (fs mode) we use the default SwapChain of 430N/A // the device, and its render target will be the same as the device's, and 430N/A // we have to set the matrix correctly. This shouldn't be a performance 430N/A // issue as render target changes are relatively rare 430N/A // no need for state change, just flush the queue 430N/A // no need for state change, just flush the queue 430N/A // In order to correctly map texels to pixels we need to 430N/A // adjust geometry by -0.5f in the transformed space. 430N/A // In order to do that we first create a translated matrix 430N/A // and then concatenate it with the world transform. 430N/A // Note that we only use non-id transform with DrawTexture, 430N/A // the rest is rendered pre-transformed. 430N/A // The identity transform for textures is handled in 430N/A // D3DVertexCacher::DrawTexture() because shifting by -0.5 for id 430N/A // transform breaks lines rendering. 430N/A " x1=%-4d y1=%-4d x2=%-4d y2=%-4d",
430N/A // no need for state change, just flush the queue 430N/A " disabling clip (== render target dimensions)");
430N/A // clip to the dimensions of the target surface, otherwise 430N/A // SetScissorRect will fail 430N/A " x1=%-4d y1=%-4d x2=%-4d y2=%-4d",
430N/A // no need for state change, just flush the queue 430N/A // REMIND: this method could be optimized: we could keep the 0N/A * This method assumes that ::SetRenderTarget has already 0N/A * been called. SetRenderTarget creates and attaches a 0N/A * depth buffer to the target surface prior to setting it 0N/A * as target surface to the device. 430N/A // save alpha blending state 430N/A // translate the clip spans by 1.0f in z direction so that the 430N/A // clip spans are rendered to the z buffer 0N/A // The depth buffer is first cleared with zeroes, which is the farthest 0N/A // plane from the viewer (our projection matrix is an inversed orthogonal 0N/A // To set the clip we'll render the clip spans with Z coordinates of 1.0f 0N/A // (the closest to the viewer). Since all rendering primitives 0N/A // have their vertices' Z coordinate set to 0.0, they will effectively be 0N/A // clipped because the Z depth test for them will fail (vertex with 1.0 0N/A // depth is closer than the one with 0.0f) 430N/A //res = BeginScene(STATE_SHAPE_CLIPOP); 430N/A // no need for state change, just flush the queue 430N/A // restore alpha blending state 430N/A // resore the transform 430N/A // Enable the depth buffer. 430N/A // We disable further updates to the depth buffer: it should only 430N/A // be updated in SetClip method. 430N/A // these are only counted for LCD glyph uploads 430N/A " rect={%-4d, %-4d, %-4d, %-4d}",
772N/A // it is safe to lock with discard because we don't care about the 772N/A // contents of dynamic textures and dstx,dsty for this case is 772N/A // always 0,0 because we are uploading into a tile texture 430N/A "D3DContext::UploadImageToTexture: could "\
430N/A // either a MaskFill tile, or a grayscale glyph 430N/A // only need to set the alpha channel (the D3D texture 430N/A // state will be setup in this case to replicate the 430N/A // alpha channel as needed) 430N/A // LCD glyph with RGB order 430N/A // alpha channel is ignored in this case 430N/A // (note that this is backwards from what one might 430N/A // expect; it appears that D3DFMT_R8G8B8 is actually 430N/A // laid out in BGR order in memory) 430N/A // alpha channel is ignored in this case 430N/A // LCD glyph with BGR order 430N/A // alpha channel is ignored in this case 430N/A // (note that this is backwards from what one might 430N/A // expect; it appears that D3DFMT_R8G8B8 is actually 430N/A // laid out in BGR order in memory) 430N/A // alpha channel is ignored in this case 430N/A // should not happen, no-op just in case... 0N/A "D3DContext::SetAlphaComposite: rule=%-1d ea=%f flags=%d",
0N/A // we can safely disable blending when: 0N/A // - comp is SrcNoEa or SrcOverNoEa, and 0N/A // - the source is opaque 430N/A // (turning off blending can have a large positive impact on performance) 430N/A " disabling alpha comp rule=%-1d ea=1.0 src=opq)",
rule);
0N/A " enabling alpha comp (rule=%-1d ea=%f)",
rule,
ea);
430N/A// Note: this method of adjusting pixel to texel mapping proved to be 430N/A// difficult to perfect. The current variation works great for id, 430N/A// scale (including all kinds of flips) transforms, but not still not 430N/A// for generic transforms. 430N/A// Since we currently only do DrawTexture with non-id transform we instead 430N/A// adjust the geometry (see D3DVertexCacher::DrawTexture(), SetTransform()) 430N/A// In order to enable this code path UpdateTextureTransforms needs to 430N/A// be called in SetTexture(), SetTransform() and ResetTranform(). 430N/A // update all used samplers, dwMaxSampler will be set to max 430N/A "updating all samplers");
430N/A // update only given sampler, dwMaxSampler will be set to it as well 430N/A // this formula works for scales and flips 430N/A // shift by .5 texel, but take into account 430N/A // the scale factor of the device transform 430N/A // REMIND: this approach is not entirely correct, 430N/A // as it only takes into account the scale of the device 0N/A * We go into the pains of maintaining the list of set textures 0N/A * instead of just calling GetTexture() and comparing the old one 0N/A * with the new one because it's actually noticeably slower to call 0N/A * GetTexture() (note that we'd have to then call Release() on the 0N/A * texture since GetTexture() increases texture's ref. count). 430N/A // REMIND: see comment at UpdateTextureTransforms 430N/A // The op is the same as last time, so we can return immediately. 430N/A // optimization: certain state changes (those marked STATE_CHANGE) 430N/A // are allowed while texturing is enabled. 430N/A // In this case, we can allow previousOp to remain as it is and 430N/A // REMIND: not necessary if we are switching to MASKOP or GLYPHOP 430N/A // (or a complex paint, for that matter), but would that be a 430N/A // worthwhile optimization? 0N/A // this will cause context reinitialization 430N/A * Compiles and links the given fragment shader program. If 430N/A * successful, this function returns a handle to the newly created shader 430N/A * program; otherwise returns 0. 430N/A "D3DContext::CreateFragmentProgram: flags=%d",
430N/A "D3DContext::CreateFragmentProgram: error creating program");
430N/A * Locates and enables a fragment program given a list of shader programs 430N/A * (ShaderInfos), using this context's state and flags as search 430N/A * parameters. The "flags" parameter is a bitwise-or'd value that helps 430N/A * differentiate one program for another; the interpretation of this value 430N/A * varies depending on the type of shader (BufImgOp, Paint, etc) but here 430N/A * it is only used to find another ShaderInfo with that same "flags" value. 430N/A "D3DContext::EnableFragmentProgram: error setting pixel shader");
430N/A "D3DContext::EnableLCDTextProgram: error setting pixel shader");
430N/A "error creating pixel shader");
430N/A "error setting pixel shader");
430N/A "D3DContext::DisableAAParallelogramProgram: " 430N/A "error clearing pixel shader");
430N/A " | CAPS_LCD_SHADER | CAPS_BIOP_SHADER | CAPS_PS20");
430N/A // Pre-PS3.0 video boards are very slow with the AA shader, so 430N/A // we will require PS30 hw even though the shader is compiled for 2.0a 430N/A// if (IsGradientInstructionExtensionSupported()) { 430N/A// contextCaps |= CAPS_AA_SHADER; 430N/A// J2dRlsTraceLn(J2D_TRACE_VERBOSE, " | CAPS_AA_SHADER"); 430N/A // This flag was not already mentioned above...