mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-02 13:53:37 +00:00
wined3d: Create the stateblock in Init3D.
This commit is contained in:
parent
430239b470
commit
861767f036
|
@ -202,24 +202,6 @@ static ULONG WINAPI IWineD3DDeviceImpl_Release(IWineD3DDevice *iface) {
|
|||
/* NOTE: You must release the parent if the object was created via a callback
|
||||
** ***************************/
|
||||
|
||||
/* Release the update stateblock */
|
||||
if(IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->updateStateBlock) > 0){
|
||||
if(This->updateStateBlock != This->stateBlock)
|
||||
FIXME("(%p) Something's still holding the Update stateblock\n",This);
|
||||
}
|
||||
This->updateStateBlock = NULL;
|
||||
{ /* because were not doing proper internal refcounts releasing the primary state block
|
||||
causes recursion with the extra checks in ResourceReleased, to avoid this we have
|
||||
to set this->stateBlock = NULL; first */
|
||||
IWineD3DStateBlock *stateBlock = (IWineD3DStateBlock *)This->stateBlock;
|
||||
This->stateBlock = NULL;
|
||||
|
||||
/* Release the stateblock */
|
||||
if(IWineD3DStateBlock_Release(stateBlock) > 0){
|
||||
FIXME("(%p) Something's still holding the Update stateblock\n",This);
|
||||
}
|
||||
}
|
||||
|
||||
if (This->resources != NULL ) {
|
||||
FIXME("(%p) Device released with resources still bound, acceptable but unexpected\n", This);
|
||||
dumpResources(This->resources);
|
||||
|
@ -1809,6 +1791,24 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface, WINED3DPR
|
|||
|
||||
/* TODO: Test if OpenGL is compiled in and loaded */
|
||||
|
||||
TRACE("(%p) : Creating stateblock\n", This);
|
||||
/* Creating the startup stateBlock - Note Special Case: 0 => Don't fill in yet! */
|
||||
hr = IWineD3DDevice_CreateStateBlock(iface,
|
||||
WINED3DSBT_INIT,
|
||||
(IWineD3DStateBlock **)&This->stateBlock,
|
||||
NULL);
|
||||
if (WINED3D_OK != hr) { /* Note: No parent needed for initial internal stateblock */
|
||||
WARN("Failed to create stateblock\n");
|
||||
return hr;
|
||||
}
|
||||
TRACE("(%p) : Created stateblock (%p)\n", This, This->stateBlock);
|
||||
This->updateStateBlock = This->stateBlock;
|
||||
IWineD3DStateBlock_AddRef((IWineD3DStateBlock*)This->updateStateBlock);
|
||||
|
||||
hr = allocate_shader_constants(This->updateStateBlock);
|
||||
if (WINED3D_OK != hr)
|
||||
return hr;
|
||||
|
||||
/* Initialize the texture unit mapping to a 1:1 mapping */
|
||||
for (state = 0; state < MAX_COMBINED_SAMPLERS; ++state) {
|
||||
if (state < GL_LIMITS(fragment_samplers)) {
|
||||
|
@ -1991,6 +1991,25 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface, D3DCB_D
|
|||
This->swapchains = NULL;
|
||||
This->NumberOfSwapChains = 0;
|
||||
|
||||
/* Release the update stateblock */
|
||||
if(IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->updateStateBlock) > 0){
|
||||
if(This->updateStateBlock != This->stateBlock)
|
||||
FIXME("(%p) Something's still holding the Update stateblock\n",This);
|
||||
}
|
||||
This->updateStateBlock = NULL;
|
||||
|
||||
{ /* because were not doing proper internal refcounts releasing the primary state block
|
||||
causes recursion with the extra checks in ResourceReleased, to avoid this we have
|
||||
to set this->stateBlock = NULL; first */
|
||||
IWineD3DStateBlock *stateBlock = (IWineD3DStateBlock *)This->stateBlock;
|
||||
This->stateBlock = NULL;
|
||||
|
||||
/* Release the stateblock */
|
||||
if(IWineD3DStateBlock_Release(stateBlock) > 0){
|
||||
FIXME("(%p) Something's still holding the Update stateblock\n",This);
|
||||
}
|
||||
}
|
||||
|
||||
This->d3d_initialized = FALSE;
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
|
|
@ -2416,7 +2416,6 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
|
|||
IWineD3DDeviceImpl *object = NULL;
|
||||
IWineD3DImpl *This = (IWineD3DImpl *)iface;
|
||||
HDC hDC;
|
||||
HRESULT temp_result;
|
||||
int i;
|
||||
|
||||
/* Validate the adapter number */
|
||||
|
@ -2462,20 +2461,6 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
|
|||
object->adapterNo = Adapter;
|
||||
object->devType = DeviceType;
|
||||
|
||||
TRACE("(%p) : Creating stateblock\n", This);
|
||||
/* Creating the startup stateBlock - Note Special Case: 0 => Don't fill in yet! */
|
||||
if (WINED3D_OK != IWineD3DDevice_CreateStateBlock((IWineD3DDevice *)object,
|
||||
WINED3DSBT_INIT,
|
||||
(IWineD3DStateBlock **)&object->stateBlock,
|
||||
NULL) || NULL == object->stateBlock) { /* Note: No parent needed for initial internal stateblock */
|
||||
WARN("Failed to create stateblock\n");
|
||||
goto create_device_error;
|
||||
}
|
||||
TRACE("(%p) : Created stateblock (%p)\n", This, object->stateBlock);
|
||||
object->updateStateBlock = object->stateBlock;
|
||||
IWineD3DStateBlock_AddRef((IWineD3DStateBlock*)object->updateStateBlock);
|
||||
/* Setup surfaces for the backbuffer, frontbuffer and depthstencil buffer */
|
||||
|
||||
select_shader_mode(&GLINFO_LOCATION, DeviceType, &object->ps_selected_mode, &object->vs_selected_mode);
|
||||
if (object->ps_selected_mode == SHADER_GLSL || object->vs_selected_mode == SHADER_GLSL) {
|
||||
object->shader_backend = &glsl_shader_backend;
|
||||
|
@ -2490,10 +2475,6 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
|
|||
* TODO: move the functionality where it belongs */
|
||||
select_shader_max_constants(object->ps_selected_mode, object->vs_selected_mode, &GLINFO_LOCATION);
|
||||
|
||||
temp_result = allocate_shader_constants(object->updateStateBlock);
|
||||
if (WINED3D_OK != temp_result)
|
||||
return temp_result;
|
||||
|
||||
object->render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DSurface *) * GL_LIMITS(buffers));
|
||||
object->fbo_color_attachments = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DSurface *) * GL_LIMITS(buffers));
|
||||
object->draw_buffers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLenum) * GL_LIMITS(buffers));
|
||||
|
@ -2512,31 +2493,6 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
|
|||
list_init(&object->patches[i]);
|
||||
}
|
||||
return WINED3D_OK;
|
||||
create_device_error:
|
||||
|
||||
/* Set the device state to error */
|
||||
object->state = WINED3DERR_DRIVERINTERNALERROR;
|
||||
|
||||
if (object->updateStateBlock != NULL) {
|
||||
IWineD3DStateBlock_Release((IWineD3DStateBlock *)object->updateStateBlock);
|
||||
object->updateStateBlock = NULL;
|
||||
}
|
||||
if (object->stateBlock != NULL) {
|
||||
IWineD3DStateBlock_Release((IWineD3DStateBlock *)object->stateBlock);
|
||||
object->stateBlock = NULL;
|
||||
}
|
||||
if (object->render_targets[0] != NULL) {
|
||||
IWineD3DSurface_Release(object->render_targets[0]);
|
||||
object->render_targets[0] = NULL;
|
||||
}
|
||||
if (object->stencilBufferTarget != NULL) {
|
||||
IWineD3DSurface_Release(object->stencilBufferTarget);
|
||||
object->stencilBufferTarget = NULL;
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, object);
|
||||
*ppReturnedDeviceInterface = NULL;
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
|
||||
}
|
||||
#undef GLINFO_LOCATION
|
||||
|
||||
|
|
Loading…
Reference in a new issue