[PATCH 4/5] d3d10core: Implement d3d10_device_IAGetIndexBuffer().

Henri Verbeet hverbeet at codeweavers.com
Tue Nov 20 15:40:21 CST 2012


---
 dlls/d3d10core/device.c   |   20 +++++++++++++++++++-
 dlls/d3d8/device.c        |    3 ++-
 dlls/d3d9/device.c        |    3 ++-
 dlls/wined3d/device.c     |    6 ++++--
 dlls/wined3d/wined3d.spec |    2 +-
 include/wine/wined3d.h    |    3 ++-
 6 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index be55387..2501da99 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -534,7 +534,25 @@ static void STDMETHODCALLTYPE d3d10_device_IAGetVertexBuffers(ID3D10Device *ifac
 static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device *iface,
         ID3D10Buffer **buffer, DXGI_FORMAT *format, UINT *offset)
 {
-    FIXME("iface %p, buffer %p, format %p, offset %p stub!\n", iface, buffer, format, offset);
+    struct d3d10_device *device = impl_from_ID3D10Device(iface);
+    enum wined3d_format_id wined3d_format;
+    struct wined3d_buffer *wined3d_buffer;
+    struct d3d10_buffer *buffer_impl;
+
+    TRACE("iface %p, buffer %p, format %p, offset %p.\n", iface, buffer, format, offset);
+
+    wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_format);
+    *format = dxgi_format_from_wined3dformat(wined3d_format);
+    *offset = 0; /* FIXME */
+    if (!wined3d_buffer)
+    {
+        *buffer = NULL;
+        return;
+    }
+
+    buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
+    *buffer = &buffer_impl->ID3D10Buffer_iface;
+    ID3D10Buffer_AddRef(*buffer);
 }
 
 static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device *iface,
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index b4bd3f9..9fa2a56 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -2303,6 +2303,7 @@ static HRESULT WINAPI d3d8_device_GetIndices(IDirect3DDevice8 *iface,
         IDirect3DIndexBuffer8 **buffer, UINT *base_vertex_index)
 {
     struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
+    enum wined3d_format_id wined3d_format;
     struct wined3d_buffer *wined3d_buffer;
     struct d3d8_indexbuffer *buffer_impl;
 
@@ -2314,7 +2315,7 @@ static HRESULT WINAPI d3d8_device_GetIndices(IDirect3DDevice8 *iface,
     /* The case from UINT to INT is safe because d3d8 will never set negative values */
     wined3d_mutex_lock();
     *base_vertex_index = wined3d_device_get_base_vertex_index(device->wined3d_device);
-    if ((wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device)))
+    if ((wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_format)))
     {
         buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
         *buffer = &buffer_impl->IDirect3DIndexBuffer8_iface;
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 0c70f96..1c707e2 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -2483,6 +2483,7 @@ static HRESULT WINAPI d3d9_device_SetIndices(IDirect3DDevice9Ex *iface, IDirect3
 static HRESULT WINAPI d3d9_device_GetIndices(IDirect3DDevice9Ex *iface, IDirect3DIndexBuffer9 **buffer)
 {
     struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
+    enum wined3d_format_id wined3d_format;
     struct wined3d_buffer *wined3d_buffer;
     struct d3d9_indexbuffer *buffer_impl;
 
@@ -2492,7 +2493,7 @@ static HRESULT WINAPI d3d9_device_GetIndices(IDirect3DDevice9Ex *iface, IDirect3
         return D3DERR_INVALIDCALL;
 
     wined3d_mutex_lock();
-    if ((wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device)))
+    if ((wined3d_buffer = wined3d_device_get_index_buffer(device->wined3d_device, &wined3d_format)))
     {
         buffer_impl = wined3d_buffer_get_parent(wined3d_buffer);
         *buffer = &buffer_impl->IDirect3DIndexBuffer9_iface;
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index ea11f70..3211038 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2236,10 +2236,12 @@ void CDECL wined3d_device_set_index_buffer(struct wined3d_device *device,
     }
 }
 
-struct wined3d_buffer * CDECL wined3d_device_get_index_buffer(const struct wined3d_device *device)
+struct wined3d_buffer * CDECL wined3d_device_get_index_buffer(const struct wined3d_device *device,
+        enum wined3d_format_id *format)
 {
-    TRACE("device %p.\n", device);
+    TRACE("device %p, format %p.\n", device, format);
 
+    *format = device->stateBlock->state.index_format;
     return device->stateBlock->state.index_buffer;
 }
 
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index e97c102..cb8304a 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -65,7 +65,7 @@
 @ cdecl wined3d_device_get_front_buffer_data(ptr long ptr)
 @ cdecl wined3d_device_get_gamma_ramp(ptr long ptr)
 @ cdecl wined3d_device_get_geometry_shader(ptr)
-@ cdecl wined3d_device_get_index_buffer(ptr)
+@ cdecl wined3d_device_get_index_buffer(ptr ptr)
 @ cdecl wined3d_device_get_light(ptr long ptr)
 @ cdecl wined3d_device_get_light_enable(ptr long ptr)
 @ cdecl wined3d_device_get_material(ptr ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 329698a..cf86df6 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2125,7 +2125,8 @@ HRESULT __cdecl wined3d_device_get_front_buffer_data(const struct wined3d_device
 void __cdecl wined3d_device_get_gamma_ramp(const struct wined3d_device *device,
         UINT swapchain_idx, struct wined3d_gamma_ramp *ramp);
 struct wined3d_shader * __cdecl wined3d_device_get_geometry_shader(const struct wined3d_device *device);
-struct wined3d_buffer * __cdecl wined3d_device_get_index_buffer(const struct wined3d_device *device);
+struct wined3d_buffer * __cdecl wined3d_device_get_index_buffer(const struct wined3d_device *device,
+        enum wined3d_format_id *format);
 HRESULT __cdecl wined3d_device_get_light(const struct wined3d_device *device,
         UINT light_idx, struct wined3d_light *light);
 HRESULT __cdecl wined3d_device_get_light_enable(const struct wined3d_device *device, UINT light_idx, BOOL *enable);
-- 
1.7.8.6




More information about the wine-patches mailing list