diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index e92be208fad..d9c337ae201 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -2711,49 +2711,23 @@ static HRESULT WINAPI d3d8_device_GetPixelShaderFunction(IDirect3DDevice8 *iface static HRESULT WINAPI d3d8_device_DrawRectPatch(IDirect3DDevice8 *iface, UINT handle, const float *segment_count, const D3DRECTPATCH_INFO *patch_info) { - struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); - HRESULT hr; - - TRACE("iface %p, handle %#x, segment_count %p, patch_info %p.\n", + FIXME("iface %p, handle %#x, segment_count %p, patch_info %p unimplemented.\n", iface, handle, segment_count, patch_info); - - wined3d_mutex_lock(); - hr = wined3d_device_draw_rect_patch(device->wined3d_device, handle, - segment_count, (const struct wined3d_rect_patch_info *)patch_info); - wined3d_mutex_unlock(); - - return hr; + return D3D_OK; } static HRESULT WINAPI d3d8_device_DrawTriPatch(IDirect3DDevice8 *iface, UINT handle, const float *segment_count, const D3DTRIPATCH_INFO *patch_info) { - struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); - HRESULT hr; - - TRACE("iface %p, handle %#x, segment_count %p, patch_info %p.\n", + FIXME("iface %p, handle %#x, segment_count %p, patch_info %p unimplemented.\n", iface, handle, segment_count, patch_info); - - wined3d_mutex_lock(); - hr = wined3d_device_draw_tri_patch(device->wined3d_device, handle, - segment_count, (const struct wined3d_tri_patch_info *)patch_info); - wined3d_mutex_unlock(); - - return hr; + return D3D_OK; } static HRESULT WINAPI d3d8_device_DeletePatch(IDirect3DDevice8 *iface, UINT handle) { - struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); - HRESULT hr; - - TRACE("iface %p, handle %#x.\n", iface, handle); - - wined3d_mutex_lock(); - hr = wined3d_device_delete_patch(device->wined3d_device, handle); - wined3d_mutex_unlock(); - - return hr; + FIXME("iface %p, handle %#x unimplemented.\n", iface, handle); + return D3DERR_INVALIDCALL; } static HRESULT WINAPI d3d8_device_SetStreamSource(IDirect3DDevice8 *iface, diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 67f9906282b..91543b54bfc 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2867,49 +2867,23 @@ static HRESULT WINAPI d3d9_device_GetPixelShaderConstantB(IDirect3DDevice9Ex *if static HRESULT WINAPI d3d9_device_DrawRectPatch(IDirect3DDevice9Ex *iface, UINT handle, const float *segment_count, const D3DRECTPATCH_INFO *patch_info) { - struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); - HRESULT hr; - - TRACE("iface %p, handle %#x, segment_count %p, patch_info %p.\n", + FIXME("iface %p, handle %#x, segment_count %p, patch_info %p unimplemented.\n", iface, handle, segment_count, patch_info); - - wined3d_mutex_lock(); - hr = wined3d_device_draw_rect_patch(device->wined3d_device, handle, - segment_count, (const struct wined3d_rect_patch_info *)patch_info); - wined3d_mutex_unlock(); - - return hr; + return D3D_OK; } static HRESULT WINAPI d3d9_device_DrawTriPatch(IDirect3DDevice9Ex *iface, UINT handle, const float *segment_count, const D3DTRIPATCH_INFO *patch_info) { - struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); - HRESULT hr; - - TRACE("iface %p, handle %#x, segment_count %p, patch_info %p.\n", + FIXME("iface %p, handle %#x, segment_count %p, patch_info %p unimplemented.\n", iface, handle, segment_count, patch_info); - - wined3d_mutex_lock(); - hr = wined3d_device_draw_tri_patch(device->wined3d_device, handle, - segment_count, (const struct wined3d_tri_patch_info *)patch_info); - wined3d_mutex_unlock(); - - return hr; + return D3D_OK; } static HRESULT WINAPI d3d9_device_DeletePatch(IDirect3DDevice9Ex *iface, UINT handle) { - struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); - HRESULT hr; - - TRACE("iface %p, handle %#x.\n", iface, handle); - - wined3d_mutex_lock(); - hr = wined3d_device_delete_patch(device->wined3d_device, handle); - wined3d_mutex_unlock(); - - return hr; + FIXME("iface %p, handle %#x unimplemented.\n", iface, handle); + return D3DERR_INVALIDCALL; } static HRESULT WINAPI d3d9_device_CreateQuery(IDirect3DDevice9Ex *iface, D3DQUERYTYPE type, IDirect3DQuery9 **query) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 3ad5f711446..e36e20d88e9 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1390,19 +1390,6 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device) resource->resource_ops->resource_unload(resource); } - TRACE("Deleting high order patches\n"); - for (i = 0; i < PATCHMAP_SIZE; ++i) - { - struct wined3d_rect_patch *patch; - struct list *e1, *e2; - - LIST_FOR_EACH_SAFE(e1, e2, &device->patches[i]) - { - patch = LIST_ENTRY(e1, struct wined3d_rect_patch, entry); - wined3d_device_delete_patch(device, patch->Handle); - } - } - /* Delete the mouse cursor texture */ if (device->cursorTexture) { @@ -4489,140 +4476,6 @@ HRESULT CDECL wined3d_device_update_surface(struct wined3d_device *device, return surface_upload_from_surface(dst_surface, dst_point, src_surface, src_rect); } -HRESULT CDECL wined3d_device_draw_rect_patch(struct wined3d_device *device, UINT handle, - const float *num_segs, const struct wined3d_rect_patch_info *rect_patch_info) -{ - struct wined3d_rect_patch *patch; - GLenum old_primitive_type; - unsigned int i; - struct list *e; - BOOL found; - - TRACE("device %p, handle %#x, num_segs %p, rect_patch_info %p.\n", - device, handle, num_segs, rect_patch_info); - - if (!(handle || rect_patch_info)) - { - /* TODO: Write a test for the return value, thus the FIXME */ - FIXME("Both handle and rect_patch_info are NULL.\n"); - return WINED3DERR_INVALIDCALL; - } - - if (handle) - { - i = PATCHMAP_HASHFUNC(handle); - found = FALSE; - LIST_FOR_EACH(e, &device->patches[i]) - { - patch = LIST_ENTRY(e, struct wined3d_rect_patch, entry); - if (patch->Handle == handle) - { - found = TRUE; - break; - } - } - - if (!found) - { - TRACE("Patch does not exist. Creating a new one\n"); - patch = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*patch)); - patch->Handle = handle; - list_add_head(&device->patches[i], &patch->entry); - } else { - TRACE("Found existing patch %p\n", patch); - } - } - else - { - /* Since opengl does not load tesselated vertex attributes into numbered vertex - * attributes we have to tesselate, read back, and draw. This needs a patch - * management structure instance. Create one. - * - * A possible improvement is to check if a vertex shader is used, and if not directly - * draw the patch. - */ - FIXME("Drawing an uncached patch. This is slow\n"); - patch = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*patch)); - } - - if (num_segs[0] != patch->numSegs[0] || num_segs[1] != patch->numSegs[1] - || num_segs[2] != patch->numSegs[2] || num_segs[3] != patch->numSegs[3] - || (rect_patch_info && memcmp(rect_patch_info, &patch->rect_patch_info, sizeof(*rect_patch_info)))) - { - HRESULT hr; - TRACE("Tesselation density or patch info changed, retesselating\n"); - - if (rect_patch_info) - patch->rect_patch_info = *rect_patch_info; - - patch->numSegs[0] = num_segs[0]; - patch->numSegs[1] = num_segs[1]; - patch->numSegs[2] = num_segs[2]; - patch->numSegs[3] = num_segs[3]; - - hr = tesselate_rectpatch(device, patch); - if (FAILED(hr)) - { - WARN("Patch tesselation failed.\n"); - - /* Do not release the handle to store the params of the patch */ - if (!handle) - HeapFree(GetProcessHeap(), 0, patch); - - return hr; - } - } - - old_primitive_type = device->stateBlock->state.gl_primitive_type; - device->stateBlock->state.gl_primitive_type = GL_TRIANGLES; - wined3d_device_draw_primitive_strided(device, patch->numSegs[0] * patch->numSegs[1] * 2 * 3, &patch->strided); - device->stateBlock->state.gl_primitive_type = old_primitive_type; - - /* Destroy uncached patches */ - if (!handle) - { - HeapFree(GetProcessHeap(), 0, patch->mem); - HeapFree(GetProcessHeap(), 0, patch); - } - return WINED3D_OK; -} - -HRESULT CDECL wined3d_device_draw_tri_patch(struct wined3d_device *device, UINT handle, - const float *segment_count, const struct wined3d_tri_patch_info *patch_info) -{ - FIXME("device %p, handle %#x, segment_count %p, patch_info %p stub!\n", - device, handle, segment_count, patch_info); - - return WINED3D_OK; -} - -HRESULT CDECL wined3d_device_delete_patch(struct wined3d_device *device, UINT handle) -{ - struct wined3d_rect_patch *patch; - struct list *e; - int i; - - TRACE("device %p, handle %#x.\n", device, handle); - - i = PATCHMAP_HASHFUNC(handle); - LIST_FOR_EACH(e, &device->patches[i]) - { - patch = LIST_ENTRY(e, struct wined3d_rect_patch, entry); - if (patch->Handle == handle) - { - TRACE("Deleting patch %p\n", patch); - list_remove(&patch->entry); - HeapFree(GetProcessHeap(), 0, patch->mem); - HeapFree(GetProcessHeap(), 0, patch); - return WINED3D_OK; - } - } - - /* TODO: Write a test for the return value */ - FIXME("Attempt to destroy nonexistent patch\n"); - return WINED3DERR_INVALIDCALL; -} - /* Do not call while under the GL lock. */ HRESULT CDECL wined3d_device_color_fill(struct wined3d_device *device, struct wined3d_surface *surface, const RECT *rect, const struct wined3d_color *color) @@ -5656,8 +5509,6 @@ HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d, device->create_parms.focus_window = focus_window; device->create_parms.flags = flags; - for (i = 0; i < PATCHMAP_SIZE; ++i) list_init(&device->patches[i]); - device->shader_backend = adapter->shader_backend; device->shader_backend->shader_get_caps(&adapter->gl_info, &shader_caps); device->vs_version = shader_caps.vs_version; diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index b70a44f2e01..fc8918a9ba1 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -4491,8 +4491,7 @@ HRESULT CDECL wined3d_get_device_caps(const struct wined3d *wined3d, UINT adapte WINED3DDEVCAPS_TEXTURESYSTEMMEMORY | WINED3DDEVCAPS_CANRENDERAFTERFLIP | WINED3DDEVCAPS_DRAWPRIMITIVES2 | - WINED3DDEVCAPS_DRAWPRIMITIVES2EX | - WINED3DDEVCAPS_RTPATCHES; + WINED3DDEVCAPS_DRAWPRIMITIVES2EX; caps->PrimitiveMiscCaps = WINED3DPMISCCAPS_CULLNONE | WINED3DPMISCCAPS_CULLCCW | diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index ed32ee22184..83c77155a85 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -779,403 +779,3 @@ void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_co /* Control goes back to the device, stateblock values may change again */ device->isInDraw = FALSE; } - -static void normalize_normal(float *n) { - float length = n[0] * n[0] + n[1] * n[1] + n[2] * n[2]; - if (length == 0.0f) return; - length = sqrtf(length); - n[0] = n[0] / length; - n[1] = n[1] / length; - n[2] = n[2] / length; -} - -/* Tesselates a high order rectangular patch into single triangles using gl evaluators - * - * The problem is that OpenGL does not offer a direct way to return the tesselated primitives, - * and they can't be sent off for rendering directly either. Tesselating is slow, so we want - * to cache the patches in a vertex buffer. But more importantly, gl can't bind generated - * attributes to numbered shader attributes, so we have to store them and rebind them as needed - * in drawprim. - * - * To read back, the opengl feedback mode is used. This creates a problem because we want - * untransformed, unlit vertices, but feedback runs everything through transform and lighting. - * Thus disable lighting and set identity matrices to get unmodified colors and positions. - * To overcome clipping find the biggest x, y and z values of the vertices in the patch and scale - * them to [-1.0;+1.0] and set the viewport up to scale them back. - * - * Normals are more tricky: Draw white vertices with 3 directional lights, and calculate the - * resulting colors back to the normals. - * - * NOTE: This function activates a context for blitting, modifies matrices & viewport, but - * does not restore it because normally a draw follows immediately afterwards. The caller is - * responsible of taking care that either the gl states are restored, or the context activated - * for drawing to reset the lastWasBlit flag. - */ -HRESULT tesselate_rectpatch(struct wined3d_device *This, struct wined3d_rect_patch *patch) -{ - unsigned int i, j, num_quads, out_vertex_size, buffer_size, d3d_out_vertex_size; - const struct wined3d_rect_patch_info *info = &patch->rect_patch_info; - float max_x = 0.0f, max_y = 0.0f, max_z = 0.0f, neg_z = 0.0f; - struct wined3d_state *state = &This->stateBlock->state; - struct wined3d_stream_info stream_info; - struct wined3d_stream_info_element *e; - const struct wined3d_gl_info *gl_info; - struct wined3d_context *context; - struct wined3d_shader *vs; - const BYTE *data; - DWORD vtxStride; - GLenum feedback_type; - GLfloat *feedbuffer; - - /* Simply activate the context for blitting. This disables all the things we don't want and - * takes care of dirtifying. Dirtifying is preferred over pushing / popping, since drawing the - * patch (as opposed to normal draws) will most likely need different changes anyway. */ - context = context_acquire(This, NULL); - gl_info = context->gl_info; - context_apply_blit_state(context, This); - - /* First, locate the position data. This is provided in a vertex buffer in - * the stateblock. Beware of VBOs. */ - vs = state->vertex_shader; - state->vertex_shader = NULL; - device_stream_info_from_declaration(This, &stream_info); - state->vertex_shader = vs; - - e = &stream_info.elements[WINED3D_FFP_POSITION]; - if (e->data.buffer_object) - { - struct wined3d_buffer *vb = state->streams[e->stream_idx].buffer; - e->data.addr = (BYTE *)((ULONG_PTR)e->data.addr + (ULONG_PTR)buffer_get_sysmem(vb, context->gl_info)); - } - vtxStride = e->stride; - data = e->data.addr - + vtxStride * info->stride * info->start_vertex_offset_height - + vtxStride * info->start_vertex_offset_width; - - /* Not entirely sure about what happens with transformed vertices */ - if (stream_info.position_transformed) FIXME("Transformed position in rectpatch generation\n"); - - if(vtxStride % sizeof(GLfloat)) { - /* glMap2f reads vertex sizes in GLfloats, the d3d stride is in bytes. - * I don't see how the stride could not be a multiple of 4, but make sure - * to check it - */ - ERR("Vertex stride is not a multiple of sizeof(GLfloat)\n"); - } - if (info->basis != WINED3D_BASIS_BEZIER) - FIXME("Basis is %s, how to handle this?\n", debug_d3dbasis(info->basis)); - if (info->degree != WINED3D_DEGREE_CUBIC) - FIXME("Degree is %s, how to handle this?\n", debug_d3ddegree(info->degree)); - - /* First, get the boundary cube of the input data */ - for (j = 0; j < info->height; ++j) - { - for (i = 0; i < info->width; ++i) - { - const float *v = (const float *)(data + vtxStride * i + vtxStride * info->stride * j); - if(fabs(v[0]) > max_x) max_x = fabsf(v[0]); - if(fabs(v[1]) > max_y) max_y = fabsf(v[1]); - if(fabs(v[2]) > max_z) max_z = fabsf(v[2]); - if(v[2] < neg_z) neg_z = v[2]; - } - } - - /* This needs some improvements in the vertex decl code */ - FIXME("Cannot find data to generate. Only generating position and normals\n"); - patch->has_normals = TRUE; - patch->has_texcoords = FALSE; - - gl_info->gl_ops.gl.p_glMatrixMode(GL_PROJECTION); - checkGLcall("glMatrixMode(GL_PROJECTION)"); - gl_info->gl_ops.gl.p_glLoadIdentity(); - checkGLcall("glLoadIdentity()"); - gl_info->gl_ops.gl.p_glScalef(1.0f / (max_x), 1.0f / (max_y), max_z == 0.0f ? 1.0f : 1.0f / (2.0f * max_z)); - gl_info->gl_ops.gl.p_glTranslatef(0.0f, 0.0f, 0.5f); - checkGLcall("glScalef"); - gl_info->gl_ops.gl.p_glViewport(-max_x, -max_y, 2 * (max_x), 2 * (max_y)); - checkGLcall("glViewport"); - - /* Some states to take care of. If we're in wireframe opengl will produce lines, and confuse - * our feedback buffer parser - */ - gl_info->gl_ops.gl.p_glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)"); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_FILLMODE)); - if (patch->has_normals) - { - static const GLfloat black[] = {0.0f, 0.0f, 0.0f, 0.0f}; - static const GLfloat red[] = {1.0f, 0.0f, 0.0f, 0.0f}; - static const GLfloat green[] = {0.0f, 1.0f, 0.0f, 0.0f}; - static const GLfloat blue[] = {0.0f, 0.0f, 1.0f, 0.0f}; - static const GLfloat white[] = {1.0f, 1.0f, 1.0f, 1.0f}; - gl_info->gl_ops.gl.p_glEnable(GL_LIGHTING); - checkGLcall("glEnable(GL_LIGHTING)"); - gl_info->gl_ops.gl.p_glLightModelfv(GL_LIGHT_MODEL_AMBIENT, black); - checkGLcall("glLightModel for MODEL_AMBIENT"); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_AMBIENT)); - - for (i = 3; i < context->gl_info->limits.lights; ++i) - { - gl_info->gl_ops.gl.p_glDisable(GL_LIGHT0 + i); - checkGLcall("glDisable(GL_LIGHT0 + i)"); - context_invalidate_state(context, STATE_ACTIVELIGHT(i)); - } - - context_invalidate_state(context, STATE_ACTIVELIGHT(0)); - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0, GL_DIFFUSE, red); - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0, GL_SPECULAR, black); - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0, GL_AMBIENT, black); - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0, GL_POSITION, red); - gl_info->gl_ops.gl.p_glEnable(GL_LIGHT0); - checkGLcall("Setting up light 1"); - context_invalidate_state(context, STATE_ACTIVELIGHT(1)); - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT1, GL_DIFFUSE, green); - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT1, GL_SPECULAR, black); - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT1, GL_AMBIENT, black); - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT1, GL_POSITION, green); - gl_info->gl_ops.gl.p_glEnable(GL_LIGHT1); - checkGLcall("Setting up light 2"); - context_invalidate_state(context, STATE_ACTIVELIGHT(2)); - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT2, GL_DIFFUSE, blue); - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT2, GL_SPECULAR, black); - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT2, GL_AMBIENT, black); - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT2, GL_POSITION, blue); - gl_info->gl_ops.gl.p_glEnable(GL_LIGHT2); - checkGLcall("Setting up light 3"); - - context_invalidate_state(context, STATE_MATERIAL); - context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORVERTEX)); - gl_info->gl_ops.gl.p_glDisable(GL_COLOR_MATERIAL); - gl_info->gl_ops.gl.p_glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, black); - gl_info->gl_ops.gl.p_glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black); - gl_info->gl_ops.gl.p_glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, white); - checkGLcall("Setting up materials"); - } - - /* Enable the needed maps. - * GL_MAP2_VERTEX_3 is needed for positional data. - * GL_AUTO_NORMAL to generate normals from the position. Do not use GL_MAP2_NORMAL. - * GL_MAP2_TEXTURE_COORD_4 for texture coords - */ - num_quads = ceilf(patch->numSegs[0]) * ceilf(patch->numSegs[1]); - out_vertex_size = 3 /* position */; - d3d_out_vertex_size = 3; - gl_info->gl_ops.gl.p_glEnable(GL_MAP2_VERTEX_3); - if (patch->has_normals && patch->has_texcoords) - { - FIXME("Texcoords not handled yet\n"); - feedback_type = GL_3D_COLOR_TEXTURE; - out_vertex_size += 8; - d3d_out_vertex_size += 7; - gl_info->gl_ops.gl.p_glEnable(GL_AUTO_NORMAL); - gl_info->gl_ops.gl.p_glEnable(GL_MAP2_TEXTURE_COORD_4); - } - else if (patch->has_texcoords) - { - FIXME("Texcoords not handled yet\n"); - feedback_type = GL_3D_COLOR_TEXTURE; - out_vertex_size += 7; - d3d_out_vertex_size += 4; - gl_info->gl_ops.gl.p_glEnable(GL_MAP2_TEXTURE_COORD_4); - } - else if (patch->has_normals) - { - feedback_type = GL_3D_COLOR; - out_vertex_size += 4; - d3d_out_vertex_size += 3; - gl_info->gl_ops.gl.p_glEnable(GL_AUTO_NORMAL); - } - else - { - feedback_type = GL_3D; - } - checkGLcall("glEnable vertex attrib generation"); - - buffer_size = num_quads * out_vertex_size * 2 /* triangle list */ * 3 /* verts per tri */ - + 4 * num_quads /* 2 triangle markers per quad + num verts in tri */; - feedbuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buffer_size * sizeof(float) * 8); - - gl_info->gl_ops.gl.p_glMap2f(GL_MAP2_VERTEX_3, - 0.0f, 1.0f, vtxStride / sizeof(float), info->width, - 0.0f, 1.0f, info->stride * vtxStride / sizeof(float), info->height, - (const GLfloat *)data); - checkGLcall("glMap2f"); - if (patch->has_texcoords) - { - gl_info->gl_ops.gl.p_glMap2f(GL_MAP2_TEXTURE_COORD_4, - 0.0f, 1.0f, vtxStride / sizeof(float), info->width, - 0.0f, 1.0f, info->stride * vtxStride / sizeof(float), info->height, - (const GLfloat *)data); - checkGLcall("glMap2f"); - } - gl_info->gl_ops.gl.p_glMapGrid2f(ceilf(patch->numSegs[0]), 0.0f, 1.0f, ceilf(patch->numSegs[1]), 0.0f, 1.0f); - checkGLcall("glMapGrid2f"); - - gl_info->gl_ops.gl.p_glFeedbackBuffer(buffer_size * 2, feedback_type, feedbuffer); - checkGLcall("glFeedbackBuffer"); - gl_info->gl_ops.gl.p_glRenderMode(GL_FEEDBACK); - - gl_info->gl_ops.gl.p_glEvalMesh2(GL_FILL, 0, ceilf(patch->numSegs[0]), 0, ceilf(patch->numSegs[1])); - checkGLcall("glEvalMesh2"); - - i = gl_info->gl_ops.gl.p_glRenderMode(GL_RENDER); - if (i == -1) - { - ERR("Feedback failed. Expected %d elements back\n", buffer_size); - HeapFree(GetProcessHeap(), 0, feedbuffer); - context_release(context); - return WINED3DERR_DRIVERINTERNALERROR; - } - else if (i != buffer_size) - { - ERR("Unexpected amount of elements returned. Expected %d, got %d\n", buffer_size, i); - HeapFree(GetProcessHeap(), 0, feedbuffer); - context_release(context); - return WINED3DERR_DRIVERINTERNALERROR; - } - else - { - TRACE("Got %d elements as expected\n", i); - } - - HeapFree(GetProcessHeap(), 0, patch->mem); - patch->mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, num_quads * 6 * d3d_out_vertex_size * sizeof(float) * 8); - i = 0; - for(j = 0; j < buffer_size; j += (3 /* num verts */ * out_vertex_size + 2 /* tri marker */)) { - if(feedbuffer[j] != GL_POLYGON_TOKEN) { - ERR("Unexpected token: %f\n", feedbuffer[j]); - continue; - } - if(feedbuffer[j + 1] != 3) { - ERR("Unexpected polygon: %f corners\n", feedbuffer[j + 1]); - continue; - } - /* Somehow there are different ideas about back / front facing, so fix up the - * vertex order - */ - patch->mem[i + 0] = feedbuffer[j + out_vertex_size * 2 + 2]; /* x, triangle 2 */ - patch->mem[i + 1] = feedbuffer[j + out_vertex_size * 2 + 3]; /* y, triangle 2 */ - patch->mem[i + 2] = (feedbuffer[j + out_vertex_size * 2 + 4] - 0.5f) * 4.0f * max_z; /* z, triangle 3 */ - if(patch->has_normals) { - patch->mem[i + 3] = feedbuffer[j + out_vertex_size * 2 + 5]; - patch->mem[i + 4] = feedbuffer[j + out_vertex_size * 2 + 6]; - patch->mem[i + 5] = feedbuffer[j + out_vertex_size * 2 + 7]; - } - i += d3d_out_vertex_size; - - patch->mem[i + 0] = feedbuffer[j + out_vertex_size * 1 + 2]; /* x, triangle 2 */ - patch->mem[i + 1] = feedbuffer[j + out_vertex_size * 1 + 3]; /* y, triangle 2 */ - patch->mem[i + 2] = (feedbuffer[j + out_vertex_size * 1 + 4] - 0.5f) * 4.0f * max_z; /* z, triangle 2 */ - if(patch->has_normals) { - patch->mem[i + 3] = feedbuffer[j + out_vertex_size * 1 + 5]; - patch->mem[i + 4] = feedbuffer[j + out_vertex_size * 1 + 6]; - patch->mem[i + 5] = feedbuffer[j + out_vertex_size * 1 + 7]; - } - i += d3d_out_vertex_size; - - patch->mem[i + 0] = feedbuffer[j + out_vertex_size * 0 + 2]; /* x, triangle 1 */ - patch->mem[i + 1] = feedbuffer[j + out_vertex_size * 0 + 3]; /* y, triangle 1 */ - patch->mem[i + 2] = (feedbuffer[j + out_vertex_size * 0 + 4] - 0.5f) * 4.0f * max_z; /* z, triangle 1 */ - if(patch->has_normals) { - patch->mem[i + 3] = feedbuffer[j + out_vertex_size * 0 + 5]; - patch->mem[i + 4] = feedbuffer[j + out_vertex_size * 0 + 6]; - patch->mem[i + 5] = feedbuffer[j + out_vertex_size * 0 + 7]; - } - i += d3d_out_vertex_size; - } - - if(patch->has_normals) { - /* Now do the same with reverse light directions */ - static const GLfloat x[] = {-1.0f, 0.0f, 0.0f, 0.0f}; - static const GLfloat y[] = { 0.0f, -1.0f, 0.0f, 0.0f}; - static const GLfloat z[] = { 0.0f, 0.0f, -1.0f, 0.0f}; - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT0, GL_POSITION, x); - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT1, GL_POSITION, y); - gl_info->gl_ops.gl.p_glLightfv(GL_LIGHT2, GL_POSITION, z); - checkGLcall("Setting up reverse light directions"); - - gl_info->gl_ops.gl.p_glRenderMode(GL_FEEDBACK); - checkGLcall("glRenderMode(GL_FEEDBACK)"); - gl_info->gl_ops.gl.p_glEvalMesh2(GL_FILL, 0, ceilf(patch->numSegs[0]), 0, ceilf(patch->numSegs[1])); - checkGLcall("glEvalMesh2"); - i = gl_info->gl_ops.gl.p_glRenderMode(GL_RENDER); - checkGLcall("glRenderMode(GL_RENDER)"); - - i = 0; - for(j = 0; j < buffer_size; j += (3 /* num verts */ * out_vertex_size + 2 /* tri marker */)) { - if(feedbuffer[j] != GL_POLYGON_TOKEN) { - ERR("Unexpected token: %f\n", feedbuffer[j]); - continue; - } - if(feedbuffer[j + 1] != 3) { - ERR("Unexpected polygon: %f corners\n", feedbuffer[j + 1]); - continue; - } - if(patch->mem[i + 3] == 0.0f) - patch->mem[i + 3] = -feedbuffer[j + out_vertex_size * 2 + 5]; - if(patch->mem[i + 4] == 0.0f) - patch->mem[i + 4] = -feedbuffer[j + out_vertex_size * 2 + 6]; - if(patch->mem[i + 5] == 0.0f) - patch->mem[i + 5] = -feedbuffer[j + out_vertex_size * 2 + 7]; - normalize_normal(patch->mem + i + 3); - i += d3d_out_vertex_size; - - if(patch->mem[i + 3] == 0.0f) - patch->mem[i + 3] = -feedbuffer[j + out_vertex_size * 1 + 5]; - if(patch->mem[i + 4] == 0.0f) - patch->mem[i + 4] = -feedbuffer[j + out_vertex_size * 1 + 6]; - if(patch->mem[i + 5] == 0.0f) - patch->mem[i + 5] = -feedbuffer[j + out_vertex_size * 1 + 7]; - normalize_normal(patch->mem + i + 3); - i += d3d_out_vertex_size; - - if(patch->mem[i + 3] == 0.0f) - patch->mem[i + 3] = -feedbuffer[j + out_vertex_size * 0 + 5]; - if(patch->mem[i + 4] == 0.0f) - patch->mem[i + 4] = -feedbuffer[j + out_vertex_size * 0 + 6]; - if(patch->mem[i + 5] == 0.0f) - patch->mem[i + 5] = -feedbuffer[j + out_vertex_size * 0 + 7]; - normalize_normal(patch->mem + i + 3); - i += d3d_out_vertex_size; - } - } - - gl_info->gl_ops.gl.p_glDisable(GL_MAP2_VERTEX_3); - gl_info->gl_ops.gl.p_glDisable(GL_AUTO_NORMAL); - gl_info->gl_ops.gl.p_glDisable(GL_MAP2_NORMAL); - gl_info->gl_ops.gl.p_glDisable(GL_MAP2_TEXTURE_COORD_4); - checkGLcall("glDisable vertex attrib generation"); - - context_release(context); - - HeapFree(GetProcessHeap(), 0, feedbuffer); - - vtxStride = 3 * sizeof(float); - if(patch->has_normals) { - vtxStride += 3 * sizeof(float); - } - if(patch->has_texcoords) { - vtxStride += 4 * sizeof(float); - } - memset(&patch->strided, 0, sizeof(patch->strided)); - patch->strided.position.format = WINED3DFMT_R32G32B32_FLOAT; - patch->strided.position.data = (BYTE *)patch->mem; - patch->strided.position.stride = vtxStride; - - if (patch->has_normals) - { - patch->strided.normal.format = WINED3DFMT_R32G32B32_FLOAT; - patch->strided.normal.data = (BYTE *)patch->mem + 3 * sizeof(float) /* pos */; - patch->strided.normal.stride = vtxStride; - } - if (patch->has_texcoords) - { - patch->strided.tex_coords[0].format = WINED3DFMT_R32G32B32A32_FLOAT; - patch->strided.tex_coords[0].data = (BYTE *)patch->mem + 3 * sizeof(float) /* pos */; - if (patch->has_normals) - patch->strided.tex_coords[0].data += 3 * sizeof(float); - patch->strided.tex_coords[0].stride = vtxStride; - } - - return WINED3D_OK; -} diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index e8e52b64b64..d8f4381631b 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -41,14 +41,11 @@ @ cdecl wined3d_device_color_fill(ptr ptr ptr ptr) @ cdecl wined3d_device_create(ptr long long ptr long long ptr ptr) @ cdecl wined3d_device_decref(ptr) -@ cdecl wined3d_device_delete_patch(ptr long) @ cdecl wined3d_device_draw_indexed_primitive(ptr long long) @ cdecl wined3d_device_draw_indexed_primitive_instanced(ptr long long long long) @ cdecl wined3d_device_draw_indexed_primitive_strided(ptr long ptr long ptr long) @ cdecl wined3d_device_draw_primitive(ptr long long) @ cdecl wined3d_device_draw_primitive_strided(ptr long ptr) -@ cdecl wined3d_device_draw_rect_patch(ptr long ptr ptr) -@ cdecl wined3d_device_draw_tri_patch(ptr long ptr ptr) @ cdecl wined3d_device_end_scene(ptr) @ cdecl wined3d_device_end_stateblock(ptr ptr) @ cdecl wined3d_device_evict_managed_resources(ptr) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 819cb824005..65a907458e2 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1581,22 +1581,6 @@ unsigned int adapter_adjust_memory(struct wined3d_adapter *adapter, int amount) BOOL initPixelFormatsNoGL(struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN; extern void add_gl_compat_wrappers(struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN; -/***************************************************************************** - * High order patch management - */ -struct wined3d_rect_patch -{ - UINT Handle; - float *mem; - struct wined3d_strided_data strided; - struct wined3d_rect_patch_info rect_patch_info; - float numSegs[4]; - char has_normals, has_texcoords; - struct list entry; -}; - -HRESULT tesselate_rectpatch(struct wined3d_device *device, struct wined3d_rect_patch *patch) DECLSPEC_HIDDEN; - enum projection_types { proj_none = 0, @@ -1781,11 +1765,6 @@ struct wined3d_device /* Context management */ struct wined3d_context **contexts; UINT context_count; - - /* High level patch management */ -#define PATCHMAP_SIZE 43 -#define PATCHMAP_HASHFUNC(x) ((x) % PATCHMAP_SIZE) /* Primitive and simple function */ - struct list patches[PATCHMAP_SIZE]; }; void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, const struct wined3d_fb_state *fb, diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 1d819fdaf1e..c50d857cb4a 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2081,7 +2081,6 @@ HRESULT __cdecl wined3d_device_create(struct wined3d *wined3d, UINT adapter_idx, enum wined3d_device_type device_type, HWND focus_window, DWORD behaviour_flags, BYTE surface_alignment, struct wined3d_device_parent *device_parent, struct wined3d_device **device); ULONG __cdecl wined3d_device_decref(struct wined3d_device *device); -HRESULT __cdecl wined3d_device_delete_patch(struct wined3d_device *device, UINT handle); HRESULT __cdecl wined3d_device_draw_indexed_primitive(struct wined3d_device *device, UINT start_idx, UINT index_count); void __cdecl wined3d_device_draw_indexed_primitive_instanced(struct wined3d_device *device, UINT start_idx, UINT index_count, UINT start_instance, UINT instance_count); @@ -2091,10 +2090,6 @@ HRESULT __cdecl wined3d_device_draw_indexed_primitive_strided(struct wined3d_dev HRESULT __cdecl wined3d_device_draw_primitive(struct wined3d_device *device, UINT start_vertex, UINT vertex_count); HRESULT __cdecl wined3d_device_draw_primitive_strided(struct wined3d_device *device, UINT vertex_count, const struct wined3d_strided_data *strided_data); -HRESULT __cdecl wined3d_device_draw_rect_patch(struct wined3d_device *device, UINT handle, - const float *num_segs, const struct wined3d_rect_patch_info *rect_patch_info); -HRESULT __cdecl wined3d_device_draw_tri_patch(struct wined3d_device *device, UINT handle, - const float *num_segs, const struct wined3d_tri_patch_info *tri_patch_info); HRESULT __cdecl wined3d_device_end_scene(struct wined3d_device *device); HRESULT __cdecl wined3d_device_end_stateblock(struct wined3d_device *device, struct wined3d_stateblock **stateblock); void __cdecl wined3d_device_evict_managed_resources(struct wined3d_device *device);