This allows the swapchain to know what depth format its window contexts have to see if the
requested depth format is compatible or a FBO fallback is needed, and it will be needed to
set the onscreen format to the requested auto depth stencil format instead of the
let's-hope-it-fits D24_UNORM_S8_UINT format.
return 0;
}
- /* In WGL both color, depth and stencil are features of a pixel format. In case of D3D they are separate.
- * You are able to add a depth + stencil surface at a later stage when you need it.
- * In order to support this properly in WineD3D we need the ability to recreate the opengl context and
- * drawable when this is required. This is very tricky as we need to reapply ALL opengl states for the new
- * context, need torecreate shaders, textures and other resources.
- *
- * The context manager already takes care of the state problem and for the other tasks code from Reset
- * can be used. These changes are way to risky during the 1.0 code freeze which is taking place right now.
- * Likely a lot of other new bugs will be exposed. For that reason request a depth stencil surface all the
- * time. It can cause a slight performance hit but fixes a lot of regressions. A fixme reminds of that this
- * issue needs to be fixed. */
- if (ds_format_desc->format != WINED3DFMT_D24_UNORM_S8_UINT)
- {
- FIXME("Add OpenGL context recreation support to SetDepthStencilSurface\n");
- ds_format_desc = getFormatDescEntry(WINED3DFMT_D24_UNORM_S8_UINT, &This->adapter->gl_info);
- }
-
getDepthStencilBits(ds_format_desc, &depthBits, &stencilBits);
for(matchtry = 0; matchtry < (sizeof(matches) / sizeof(matches[0])) && !iPixelFormat; matchtry++) {
* pPresentParameters: contains the pixelformats to use for onscreen rendering
*
*****************************************************************************/
-struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3DSurfaceImpl *target)
+struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3DSurfaceImpl *target,
+ const struct wined3d_format_desc *ds_format_desc)
{
IWineD3DDeviceImpl *device = swapchain->device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_format_desc *color_format_desc;
- const struct wined3d_format_desc *ds_format_desc;
struct wined3d_context *ret;
PIXELFORMATDESCRIPTOR pfd;
BOOL auxBuffers = FALSE;
goto out;
}
- ds_format_desc = getFormatDescEntry(WINED3DFMT_UNKNOWN, gl_info);
color_format_desc = target->resource.format_desc;
/* In case of ORM_BACKBUFFER, make sure to request an alpha component for
}
target = (IWineD3DSurfaceImpl *)(swapchain->backBuffer ? swapchain->backBuffer[0] : swapchain->frontBuffer);
- if (!(context = context_create(swapchain, target)))
+ if (!(context = context_create(swapchain, target, swapchain->ds_format)))
{
WARN("Failed to create context.\n");
HeapFree(GetProcessHeap(), 0, swapchain->context);
if (surface_type == SURFACE_OPENGL)
{
- if (!(swapchain->context[0] = context_create(swapchain, (IWineD3DSurfaceImpl *)swapchain->frontBuffer)))
+ const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
+
+ /* In WGL both color, depth and stencil are features of a pixel format. In case of D3D they are separate.
+ * You are able to add a depth + stencil surface at a later stage when you need it.
+ * In order to support this properly in WineD3D we need the ability to recreate the opengl context and
+ * drawable when this is required. This is very tricky as we need to reapply ALL opengl states for the new
+ * context, need torecreate shaders, textures and other resources.
+ *
+ * The context manager already takes care of the state problem and for the other tasks code from Reset
+ * can be used. These changes are way to risky during the 1.0 code freeze which is taking place right now.
+ * Likely a lot of other new bugs will be exposed. For that reason request a depth stencil surface all the
+ * time. It can cause a slight performance hit but fixes a lot of regressions. A fixme reminds of that this
+ * issue needs to be fixed. */
+ if (!present_parameters->EnableAutoDepthStencil
+ || swapchain->presentParms.AutoDepthStencilFormat != WINED3DFMT_D24_UNORM_S8_UINT)
+ {
+ FIXME("Add OpenGL context recreation support to SetDepthStencilSurface\n");
+ }
+ swapchain->ds_format = getFormatDescEntry(WINED3DFMT_D24_UNORM_S8_UINT, gl_info);
+ swapchain->context[0] = context_create(swapchain, (IWineD3DSurfaceImpl *)swapchain->frontBuffer,
+ swapchain->ds_format);
+ if (!swapchain->context[0])
{
WARN("Failed to create context.\n");
hr = WINED3DERR_NOTAVAILABLE;
TRACE("Creating a new context for swapchain %p, thread %d\n", This, GetCurrentThreadId());
- if (!(ctx = context_create(This, (IWineD3DSurfaceImpl *)This->frontBuffer)))
+ if (!(ctx = context_create(This, (IWineD3DSurfaceImpl *)This->frontBuffer, This->ds_format)))
{
ERR("Failed to create a new context for the swapchain\n");
return NULL;
GLenum fbo_target, IWineD3DSurface *depth_stencil, BOOL use_render_buffer) DECLSPEC_HIDDEN;
void context_attach_surface_fbo(const struct wined3d_context *context,
GLenum fbo_target, DWORD idx, IWineD3DSurface *surface) DECLSPEC_HIDDEN;
-struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3DSurfaceImpl *target) DECLSPEC_HIDDEN;
+struct wined3d_context *context_create(IWineD3DSwapChainImpl *swapchain, IWineD3DSurfaceImpl *target,
+ const struct wined3d_format_desc *ds_format_desc) DECLSPEC_HIDDEN;
void context_destroy(IWineD3DDeviceImpl *This, struct wined3d_context *context) DECLSPEC_HIDDEN;
void context_free_event_query(struct wined3d_event_query *query) DECLSPEC_HIDDEN;
void context_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
WINED3DFORMAT orig_fmt;
WINED3DGAMMARAMP orig_gamma;
BOOL render_to_fbo;
+ const struct wined3d_format_desc *ds_format;
long prev_time, frames; /* Performance tracking */
unsigned int vSyncCounter;