HRESULT NineSwapChain9_ctor( struct NineSwapChain9 *This, struct NineUnknownParams *pParams, BOOL implicit, ID3DPresent *pPresent, struct d3dadapter9_context *pCTX, HWND hFocusWindow ) { D3DPRESENT_PARAMETERS params; HRESULT hr; DBG("This=%p pDevice=%p pPresent=%p pCTX=%p hFocusWindow=%p\n", This, pParams->device, pPresent, pCTX, hFocusWindow); hr = NineUnknown_ctor(&This->base, pParams); if (FAILED(hr)) return hr; This->screen = NineDevice9_GetScreen(This->base.device); This->pipe = NineDevice9_GetPipe(This->base.device); This->cso = NineDevice9_GetCSO(This->base.device); This->implicit = implicit; This->actx = pCTX; This->present = pPresent; ID3DPresent_AddRef(pPresent); hr = ID3DPresent_GetPresentParameters(This->present, ¶ms); if (FAILED(hr)) return hr; if (!params.hDeviceWindow) params.hDeviceWindow = hFocusWindow; return NineSwapChain9_Resize(This, ¶ms); }
HRESULT NineSwapChain9_ctor( struct NineSwapChain9 *This, struct NineUnknownParams *pParams, BOOL implicit, ID3DPresent *pPresent, D3DPRESENT_PARAMETERS *pPresentationParameters, struct d3dadapter9_context *pCTX, HWND hFocusWindow, D3DDISPLAYMODEEX *mode ) { HRESULT hr; DBG("This=%p pDevice=%p pPresent=%p pCTX=%p hFocusWindow=%p\n", This, pParams->device, pPresent, pCTX, hFocusWindow); hr = NineUnknown_ctor(&This->base, pParams); if (FAILED(hr)) return hr; This->screen = NineDevice9_GetScreen(This->base.device); This->implicit = implicit; This->actx = pCTX; This->present = pPresent; This->mode = NULL; ID3DPresent_AddRef(pPresent); if (!This->actx->thread_submit && This->base.device->minor_version_num > 2) { D3DPRESENT_PARAMETERS2 params2; memset(¶ms2, 0, sizeof(D3DPRESENT_PARAMETERS2)); params2.AllowDISCARDDelayedRelease = This->actx->discard_delayed_release; params2.TearFreeDISCARD = This->actx->tearfree_discard; ID3DPresent_SetPresentParameters2(pPresent, ¶ms2); } if (!pPresentationParameters->hDeviceWindow) pPresentationParameters->hDeviceWindow = hFocusWindow; This->rendering_done = FALSE; This->pool = NULL; return NineSwapChain9_Resize(This, pPresentationParameters, mode); }
HRESULT NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 *This, const int sRGB ) { const struct util_format_description *desc; struct pipe_context *pipe; struct pipe_screen *screen = NineDevice9_GetScreen(This->base.base.device); struct pipe_resource *resource = This->base.resource; struct pipe_sampler_view templ; enum pipe_format srgb_format; unsigned i; uint8_t swizzle[4]; DBG("This=%p sRGB=%d\n", This, sRGB); if (unlikely(!resource)) { if (unlikely(This->format == D3DFMT_NULL)) return D3D_OK; NineBaseTexture9_Dump(This); } assert(resource); pipe_sampler_view_reference(&This->view[sRGB], NULL); swizzle[0] = PIPE_SWIZZLE_X; swizzle[1] = PIPE_SWIZZLE_Y; swizzle[2] = PIPE_SWIZZLE_Z; swizzle[3] = PIPE_SWIZZLE_W; desc = util_format_description(resource->format); if (desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) { /* msdn doc is incomplete here and wrong. * The only formats that can be read directly here * are DF16, DF24 and INTZ. * Tested on win the swizzle is * R = depth, G = B = 0, A = 1 for DF16 and DF24 * R = G = B = A = depth for INTZ * For the other ZS formats that can't be read directly * but can be used as shadow map, the result is duplicated on * all channel */ if (This->format == D3DFMT_DF16 || This->format == D3DFMT_DF24) { swizzle[1] = PIPE_SWIZZLE_0; swizzle[2] = PIPE_SWIZZLE_0; swizzle[3] = PIPE_SWIZZLE_1; } else { swizzle[1] = PIPE_SWIZZLE_X; swizzle[2] = PIPE_SWIZZLE_X; swizzle[3] = PIPE_SWIZZLE_X; } } else if (resource->format == PIPE_FORMAT_RGTC2_UNORM) { swizzle[0] = PIPE_SWIZZLE_Y; swizzle[1] = PIPE_SWIZZLE_X; swizzle[2] = PIPE_SWIZZLE_1; swizzle[3] = PIPE_SWIZZLE_1; } else if (resource->format != PIPE_FORMAT_A8_UNORM && resource->format != PIPE_FORMAT_RGTC1_UNORM) { /* exceptions: * A8 should have 0.0 as default values for RGB. * ATI1/RGTC1 should be r 0 0 1 (tested on windows). * It is already what gallium does. All the other ones * should have 1.0 for non-defined values */ for (i = 0; i < 4; i++) { if (SWIZZLE_TO_REPLACE(desc->swizzle[i])) swizzle[i] = PIPE_SWIZZLE_1; } } /* if requested and supported, convert to the sRGB format */ srgb_format = util_format_srgb(resource->format); if (sRGB && srgb_format != PIPE_FORMAT_NONE && screen->is_format_supported(screen, srgb_format, resource->target, 0, 0, resource->bind)) templ.format = srgb_format; else templ.format = resource->format; templ.u.tex.first_layer = 0; templ.u.tex.last_layer = resource->target == PIPE_TEXTURE_3D ? resource->depth0 - 1 : resource->array_size - 1; templ.u.tex.first_level = 0; templ.u.tex.last_level = resource->last_level; templ.swizzle_r = swizzle[0]; templ.swizzle_g = swizzle[1]; templ.swizzle_b = swizzle[2]; templ.swizzle_a = swizzle[3]; templ.target = resource->target; pipe = nine_context_get_pipe_acquire(This->base.base.device); This->view[sRGB] = pipe->create_sampler_view(pipe, resource, &templ); nine_context_get_pipe_release(This->base.base.device); DBG("sampler view = %p(resource = %p)\n", This->view[sRGB], resource); return This->view ? D3D_OK : D3DERR_DRIVERINTERNALERROR; }