diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 0967bd83cdb..c1ce5f85a9b 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -408,8 +408,7 @@ static void device_trace_strided_stream_info(const struct wined3d_stream_info *s void device_update_stream_info(IWineD3DDeviceImpl *device, const struct wined3d_gl_info *gl_info) { struct wined3d_stream_info *stream_info = &device->strided_streams; - IWineD3DStateBlockImpl *stateblock = device->stateBlock; - BOOL vs = stateblock->state.vertex_shader && device->vs_selected_mode != SHADER_NONE; + const struct wined3d_state *state = &device->stateBlock->state; BOOL fixup = FALSE; if (device->up_strided) @@ -422,12 +421,12 @@ void device_update_stream_info(IWineD3DDeviceImpl *device, const struct wined3d_ else { TRACE("============================= Vertex Declaration =============================\n"); - device_stream_info_from_declaration(device, vs, stream_info, &fixup); + device_stream_info_from_declaration(device, !!state->vertex_shader, stream_info, &fixup); } - if (vs && !stream_info->position_transformed) + if (state->vertex_shader && !stream_info->position_transformed) { - if (stateblock->state.vertex_declaration->half_float_conv_needed && !fixup) + if (state->vertex_declaration->half_float_conv_needed && !fixup) { TRACE("Using drawStridedSlow with vertex shaders for FLOAT16 conversion.\n"); device->useDrawStridedSlow = TRUE; @@ -1515,6 +1514,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexShader(IWineD3DDevice *ifac IWineD3DVertexShaderImpl *object; HRESULT hr; + if (This->vs_selected_mode == SHADER_NONE) + return WINED3DERR_INVALIDCALL; + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); if (!object) { @@ -1575,6 +1577,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreatePixelShader(IWineD3DDevice *iface IWineD3DPixelShaderImpl *object; HRESULT hr; + if (This->ps_selected_mode == SHADER_NONE) + return WINED3DERR_INVALIDCALL; + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); if (!object) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 663a9d44c88..036d6f419bd 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3023,14 +3023,13 @@ static inline BOOL use_vs(IWineD3DStateBlockImpl *stateblock) * IWineD3DDeviceImpl_FindTexUnitMap(). This is safe because * stateblock->vertexShader implies a vertex declaration instead of ddraw * style strided data. */ - return (stateblock->state.vertex_shader - && !stateblock->state.vertex_declaration->position_transformed - && stateblock->device->vs_selected_mode != SHADER_NONE); + return stateblock->state.vertex_shader + && !stateblock->state.vertex_declaration->position_transformed; } static inline BOOL use_ps(IWineD3DStateBlockImpl *stateblock) { - return (stateblock->state.pixel_shader && stateblock->device->ps_selected_mode != SHADER_NONE); + return !!stateblock->state.pixel_shader; } /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */