ReactOS 0.4.17-dev-966-gf06eace
render.c File Reference
#include "d3dx9_private.h"
Include dependency graph for render.c:

Go to the source code of this file.

Classes

struct  device_state
 
struct  render_to_surface
 
struct  render_to_envmap
 

Enumerations

enum  render_state { INITIAL , CUBE_BEGIN , CUBE_FACE }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3dx)
 
static HRESULT device_state_init (IDirect3DDevice9 *device, struct device_state *state)
 
static void device_state_capture (IDirect3DDevice9 *device, struct device_state *state)
 
static void device_state_restore (IDirect3DDevice9 *device, struct device_state *state)
 
static void device_state_release (struct device_state *state)
 
static struct render_to_surface * impl_from_ID3DXRenderToSurface (ID3DXRenderToSurface *iface)
 
static HRESULT WINAPI D3DXRenderToSurface_QueryInterface (ID3DXRenderToSurface *iface, REFIID riid, void **out)
 
static ULONG WINAPI D3DXRenderToSurface_AddRef (ID3DXRenderToSurface *iface)
 
static ULONG WINAPI D3DXRenderToSurface_Release (ID3DXRenderToSurface *iface)
 
static HRESULT WINAPI D3DXRenderToSurface_GetDevice (ID3DXRenderToSurface *iface, IDirect3DDevice9 **device)
 
static HRESULT WINAPI D3DXRenderToSurface_GetDesc (ID3DXRenderToSurface *iface, D3DXRTS_DESC *desc)
 
static HRESULT WINAPI D3DXRenderToSurface_BeginScene (ID3DXRenderToSurface *iface, IDirect3DSurface9 *surface, const D3DVIEWPORT9 *viewport)
 
static HRESULT WINAPI D3DXRenderToSurface_EndScene (ID3DXRenderToSurface *iface, DWORD filter)
 
static HRESULT WINAPI D3DXRenderToSurface_OnLostDevice (ID3DXRenderToSurface *iface)
 
static HRESULT WINAPI D3DXRenderToSurface_OnResetDevice (ID3DXRenderToSurface *iface)
 
HRESULT WINAPI D3DXCreateRenderToSurface (IDirect3DDevice9 *device, UINT width, UINT height, D3DFORMAT format, BOOL depth_stencil, D3DFORMAT depth_stencil_format, ID3DXRenderToSurface **out)
 
static void copy_render_target_to_cube_texture_face (IDirect3DCubeTexture9 *cube_texture, D3DCUBEMAP_FACES face, IDirect3DSurface9 *render_target, DWORD filter)
 
static struct render_to_envmap * impl_from_ID3DXRenderToEnvMap (ID3DXRenderToEnvMap *iface)
 
static HRESULT WINAPI D3DXRenderToEnvMap_QueryInterface (ID3DXRenderToEnvMap *iface, REFIID riid, void **out)
 
static ULONG WINAPI D3DXRenderToEnvMap_AddRef (ID3DXRenderToEnvMap *iface)
 
static ULONG WINAPI D3DXRenderToEnvMap_Release (ID3DXRenderToEnvMap *iface)
 
static HRESULT WINAPI D3DXRenderToEnvMap_GetDevice (ID3DXRenderToEnvMap *iface, IDirect3DDevice9 **device)
 
static HRESULT WINAPI D3DXRenderToEnvMap_GetDesc (ID3DXRenderToEnvMap *iface, D3DXRTE_DESC *desc)
 
static HRESULT WINAPI D3DXRenderToEnvMap_BeginCube (ID3DXRenderToEnvMap *iface, IDirect3DCubeTexture9 *texture)
 
static HRESULT WINAPI D3DXRenderToEnvMap_BeginSphere (ID3DXRenderToEnvMap *iface, IDirect3DTexture9 *texture)
 
static HRESULT WINAPI D3DXRenderToEnvMap_BeginHemisphere (ID3DXRenderToEnvMap *iface, IDirect3DTexture9 *pos_z_texture, IDirect3DTexture9 *neg_z_texture)
 
static HRESULT WINAPI D3DXRenderToEnvMap_BeginParabolic (ID3DXRenderToEnvMap *iface, IDirect3DTexture9 *pos_z_texture, IDirect3DTexture9 *neg_z_texture)
 
static HRESULT WINAPI D3DXRenderToEnvMap_Face (ID3DXRenderToEnvMap *iface, D3DCUBEMAP_FACES face, DWORD filter)
 
static HRESULT WINAPI D3DXRenderToEnvMap_End (ID3DXRenderToEnvMap *iface, DWORD filter)
 
static HRESULT WINAPI D3DXRenderToEnvMap_OnLostDevice (ID3DXRenderToEnvMap *iface)
 
static HRESULT WINAPI D3DXRenderToEnvMap_OnResetDevice (ID3DXRenderToEnvMap *iface)
 
HRESULT WINAPI D3DXCreateRenderToEnvMap (IDirect3DDevice9 *device, UINT size, UINT mip_levels, D3DFORMAT format, BOOL depth_stencil, D3DFORMAT depth_stencil_format, ID3DXRenderToEnvMap **out)
 

Variables

static const ID3DXRenderToSurfaceVtbl render_to_surface_vtbl
 
static const ID3DXRenderToEnvMapVtbl render_to_envmap_vtbl
 

Enumeration Type Documentation

◆ render_state

Enumerator
INITIAL 
CUBE_BEGIN 
CUBE_FACE 

Definition at line 419 of file render.c.

420{
421 INITIAL,
422
425};
@ CUBE_BEGIN
Definition: render.c:423
@ CUBE_FACE
Definition: render.c:424
@ INITIAL
Definition: render.c:421

Function Documentation

◆ copy_render_target_to_cube_texture_face()

static void copy_render_target_to_cube_texture_face ( IDirect3DCubeTexture9 *  cube_texture,
D3DCUBEMAP_FACES  face,
IDirect3DSurface9 *  render_target,
DWORD  filter 
)
static

Definition at line 447 of file render.c.

449{
450 HRESULT hr;
451 IDirect3DSurface9 *cube_surface;
452
453 IDirect3DCubeTexture9_GetCubeMapSurface(cube_texture, face, 0, &cube_surface);
454
455 hr = D3DXLoadSurfaceFromSurface(cube_surface, NULL, NULL, render_target, NULL, NULL, filter, 0);
456 if (FAILED(hr))
457 ERR("Copying render target data to surface failed, hr %#lx.\n", hr);
458
459 IDirect3DSurface9_Release(cube_surface);
460}
#define ERR(fmt,...)
Definition: precomp.h:57
#define IDirect3DSurface9_Release(p)
Definition: d3d9.h:450
#define IDirect3DCubeTexture9_GetCubeMapSurface(p, a, b, c)
Definition: d3d9.h:766
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
HRESULT WINAPI D3DXLoadSurfaceFromSurface(IDirect3DSurface9 *dst_surface, const PALETTEENTRY *dst_palette, const RECT *dst_rect, IDirect3DSurface9 *src_surface, const PALETTEENTRY *src_palette, const RECT *src_rect, DWORD filter, D3DCOLOR color_key)
Definition: surface.c:2765
DWORD IDirect3DSurface9
Definition: dxva2api.idl:23
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define FAILED(hr)
Definition: intsafe.h:51
Definition: filter.c:165

Referenced by D3DXRenderToEnvMap_End(), and D3DXRenderToEnvMap_Face().

◆ D3DXCreateRenderToEnvMap()

HRESULT WINAPI D3DXCreateRenderToEnvMap ( IDirect3DDevice9 *  device,
UINT  size,
UINT  mip_levels,
D3DFORMAT  format,
BOOL  depth_stencil,
D3DFORMAT  depth_stencil_format,
ID3DXRenderToEnvMap **  out 
)

Definition at line 748 of file render.c.

755{
756 HRESULT hr;
757 struct render_to_envmap *render;
758
759 TRACE("(%p, %u, %u, %#x, %d, %#x, %p)\n", device, size, mip_levels,
760 format, depth_stencil, depth_stencil_format, out);
761
762 if (!device || !out) return D3DERR_INVALIDCALL;
763
766 if (FAILED(hr)) return hr;
767
768 render = malloc(sizeof(*render));
769 if (!render) return E_OUTOFMEMORY;
770
771 render->ID3DXRenderToEnvMap_iface.lpVtbl = &render_to_envmap_vtbl;
772 render->ref = 1;
773
774 render->desc.Size = size;
775 render->desc.MipLevels = mip_levels;
776 render->desc.Format = format;
777 render->desc.DepthStencil = depth_stencil;
778 render->desc.DepthStencilFormat = depth_stencil_format;
779
780 render->state = INITIAL;
781 render->render_target = NULL;
782 render->depth_stencil = NULL;
783 render->dst_cube_texture = NULL;
784
785 hr = device_state_init(device, &render->previous_device_state);
786 if (FAILED(hr))
787 {
788 free(render);
789 return hr;
790 }
791
793 render->device = device;
794
795 *out = &render->ID3DXRenderToEnvMap_iface;
796 return D3D_OK;
797}
#define D3DERR_INVALIDCALL
Definition: d3d10_private.h:42
#define D3DUSAGE_RENDERTARGET
Definition: d3d8types.h:91
@ D3DPOOL_DEFAULT
Definition: d3d8types.h:709
#define IDirect3DDevice9_AddRef(p)
Definition: d3d9.h:1335
#define D3D_OK
Definition: d3d.h:106
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
static HRESULT device_state_init(IDirect3DDevice9 *device, struct device_state *state)
Definition: render.c:33
static const ID3DXRenderToEnvMapVtbl render_to_envmap_vtbl
Definition: render.c:729
HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UINT *width, UINT *height, UINT *miplevels, DWORD usage, D3DFORMAT *format, D3DPOOL pool)
Definition: texture.c:411
static void depth_stencil(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
Definition: ffp_gl.c:766
GLsizeiptr size
Definition: glext.h:5919
#define TRACE(s)
Definition: solgame.cpp:4
static void render(void)
Definition: ssstars.c:272
Definition: devices.h:37
IDirect3DDevice9 * device
Definition: render.c:432
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

Referenced by test_D3DXCreateRenderToEnvMap(), test_ID3DXRenderToEnvMap(), and test_ID3DXRenderToEnvMap_cube_map().

◆ D3DXCreateRenderToSurface()

HRESULT WINAPI D3DXCreateRenderToSurface ( IDirect3DDevice9 *  device,
UINT  width,
UINT  height,
D3DFORMAT  format,
BOOL  depth_stencil,
D3DFORMAT  depth_stencil_format,
ID3DXRenderToSurface **  out 
)

Definition at line 372 of file render.c.

379{
380 HRESULT hr;
382
383 TRACE("device %p, width %u, height %u, format %#x, depth_stencil %#x, depth_stencil_format %#x, out %p.\n",
384 device, width, height, format, depth_stencil, depth_stencil_format, out);
385
386 if (!device || !out) return D3DERR_INVALIDCALL;
387
388 render = malloc(sizeof(struct render_to_surface));
389 if (!render) return E_OUTOFMEMORY;
390
391 render->ID3DXRenderToSurface_iface.lpVtbl = &render_to_surface_vtbl;
392 render->ref = 1;
393
394 render->desc.Width = width;
395 render->desc.Height = height;
396 render->desc.Format = format;
397 render->desc.DepthStencil = depth_stencil;
398 render->desc.DepthStencilFormat = depth_stencil_format;
399
400 render->dst_surface = NULL;
401 render->render_target = NULL;
402 render->depth_stencil = NULL;
403
404 hr = device_state_init(device, &render->previous_state);
405 if (FAILED(hr))
406 {
407 free(render);
408 return hr;
409 }
410
412 render->device = device;
413
414 *out = &render->ID3DXRenderToSurface_iface;
415 return D3D_OK;
416}
static const ID3DXRenderToSurfaceVtbl render_to_surface_vtbl
Definition: render.c:357
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
IDirect3DDevice9 * device
Definition: render.c:112

Referenced by check_ID3DXRenderToSurface(), test_D3DXCreateRenderToSurface(), test_ID3DXRenderToSurface(), and test_ID3DXRenderToSurface_device_state().

◆ D3DXRenderToEnvMap_AddRef()

static ULONG WINAPI D3DXRenderToEnvMap_AddRef ( ID3DXRenderToEnvMap *  iface)
static

Definition at line 487 of file render.c.

488{
491
492 TRACE("%p increasing refcount to %lu.\n", iface, ref);
493
494 return ref;
495}
#define InterlockedIncrement
Definition: armddk.h:53
static struct render_to_envmap * impl_from_ID3DXRenderToEnvMap(ID3DXRenderToEnvMap *iface)
Definition: render.c:462
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

◆ D3DXRenderToEnvMap_BeginCube()

static HRESULT WINAPI D3DXRenderToEnvMap_BeginCube ( ID3DXRenderToEnvMap *  iface,
IDirect3DCubeTexture9 *  texture 
)
static

Definition at line 549 of file render.c.

551{
553 HRESULT hr;
554 D3DSURFACE_DESC level_desc;
555
556 TRACE("iface %p, texture %p.\n", iface, texture);
557
558 if (!texture) return D3DERR_INVALIDCALL;
559
560 if (render->state != INITIAL) return D3DERR_INVALIDCALL;
561
563 if (level_desc.Format != render->desc.Format || level_desc.Width != render->desc.Size)
564 return D3DERR_INVALIDCALL;
565
566 if (!(level_desc.Usage & D3DUSAGE_RENDERTARGET))
567 {
568 hr = IDirect3DDevice9_CreateRenderTarget(render->device, level_desc.Width, level_desc.Height,
569 level_desc.Format, level_desc.MultiSampleType, level_desc.MultiSampleQuality,
570 TRUE, &render->render_target, NULL);
571 if (FAILED(hr)) goto cleanup;
573 }
574
575 if (render->desc.DepthStencil)
576 {
577 hr = IDirect3DDevice9_CreateDepthStencilSurface(render->device, level_desc.Width, level_desc.Height,
578 render->desc.DepthStencilFormat, level_desc.MultiSampleType, level_desc.MultiSampleQuality,
579 TRUE, &render->depth_stencil, NULL);
580 if (FAILED(hr)) goto cleanup;
581 }
582
584 render->dst_cube_texture = texture;
585 render->state = CUBE_BEGIN;
586 return D3D_OK;
587
588cleanup:
589 if (render->dst_cube_texture)
590 IDirect3DCubeTexture9_Release(render->dst_cube_texture);
591 render->dst_cube_texture = NULL;
592
593 if (render->render_target) IDirect3DSurface9_Release(render->render_target);
594 render->render_target = NULL;
595 if (render->depth_stencil) IDirect3DSurface9_Release(render->depth_stencil);
596 render->depth_stencil = NULL;
597
598 return hr;
599}
#define IDirect3DCubeTexture9_AddRef(p)
Definition: d3d9.h:746
#define IDirect3DCubeTexture9_Release(p)
Definition: d3d9.h:747
#define IDirect3DDevice9_CreateDepthStencilSurface(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1364
#define IDirect3DCubeTexture9_GetLevelDesc(p, a, b)
Definition: d3d9.h:765
#define IDirect3DDevice9_CreateRenderTarget(p, a, b, c, d, e, f, g, h)
Definition: d3d9.h:1363
#define TRUE
Definition: types.h:120
static void cleanup(void)
Definition: main.c:1335
GLenum GLuint texture
Definition: glext.h:6295
D3DFORMAT Format
Definition: d3d8types.h:1170
DWORD MultiSampleQuality
Definition: d3d9types.h:1520
D3DMULTISAMPLE_TYPE MultiSampleType
Definition: d3d8types.h:1175

◆ D3DXRenderToEnvMap_BeginHemisphere()

static HRESULT WINAPI D3DXRenderToEnvMap_BeginHemisphere ( ID3DXRenderToEnvMap *  iface,
IDirect3DTexture9 *  pos_z_texture,
IDirect3DTexture9 *  neg_z_texture 
)
static

Definition at line 608 of file render.c.

611{
612 FIXME("iface %p, pos_z_texture %p, neg_z_texture %p stub!\n", iface, pos_z_texture, neg_z_texture);
613 return E_NOTIMPL;
614}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ D3DXRenderToEnvMap_BeginParabolic()

static HRESULT WINAPI D3DXRenderToEnvMap_BeginParabolic ( ID3DXRenderToEnvMap *  iface,
IDirect3DTexture9 *  pos_z_texture,
IDirect3DTexture9 *  neg_z_texture 
)
static

Definition at line 616 of file render.c.

619{
620 FIXME("iface %p, pos_z_texture %p, neg_z_texture %p stub!\n", iface, pos_z_texture, neg_z_texture);
621 return E_NOTIMPL;
622}

◆ D3DXRenderToEnvMap_BeginSphere()

static HRESULT WINAPI D3DXRenderToEnvMap_BeginSphere ( ID3DXRenderToEnvMap *  iface,
IDirect3DTexture9 *  texture 
)
static

Definition at line 601 of file render.c.

603{
604 FIXME("iface %p, texture %p stub!\n", iface, texture);
605 return E_NOTIMPL;
606}

◆ D3DXRenderToEnvMap_End()

static HRESULT WINAPI D3DXRenderToEnvMap_End ( ID3DXRenderToEnvMap *  iface,
DWORD  filter 
)
static

Definition at line 677 of file render.c.

679{
681
682 TRACE("iface %p, filter %#lx.\n", iface, filter);
683
684 if (render->state == INITIAL) return D3DERR_INVALIDCALL;
685
686 if (render->state == CUBE_FACE)
687 {
689 if (render->render_target)
691 render->render_target, render->filter);
692
693 device_state_restore(render->device, &render->previous_device_state);
694 }
695
696 D3DXFilterTexture((IDirect3DBaseTexture9 *)render->dst_cube_texture, NULL, 0, filter);
697
698 if (render->render_target)
699 {
700 IDirect3DSurface9_Release(render->render_target);
701 render->render_target = NULL;
702 }
703
704 if (render->depth_stencil)
705 {
706 IDirect3DSurface9_Release(render->depth_stencil);
707 render->depth_stencil = NULL;
708 }
709
710 IDirect3DCubeTexture9_Release(render->dst_cube_texture);
711 render->dst_cube_texture = NULL;
712
713 render->state = INITIAL;
714 return D3D_OK;
715}
#define IDirect3DDevice9_EndScene(p)
Definition: d3d9.h:1377
static void device_state_restore(IDirect3DDevice9 *device, struct device_state *state)
Definition: render.c:70
static void copy_render_target_to_cube_texture_face(IDirect3DCubeTexture9 *cube_texture, D3DCUBEMAP_FACES face, IDirect3DSurface9 *render_target, DWORD filter)
Definition: render.c:447
HRESULT WINAPI D3DXFilterTexture(IDirect3DBaseTexture9 *texture, const PALETTEENTRY *palette, UINT srclevel, DWORD filter)
Definition: texture.c:48

◆ D3DXRenderToEnvMap_Face()

static HRESULT WINAPI D3DXRenderToEnvMap_Face ( ID3DXRenderToEnvMap *  iface,
D3DCUBEMAP_FACES  face,
DWORD  filter 
)
static

Definition at line 624 of file render.c.

627{
629 HRESULT hr;
630 unsigned int i;
631
632 TRACE("iface %p, face %u, filter %#lx.\n", iface, face, filter);
633
634 if (render->state == CUBE_FACE)
635 {
637 if (render->render_target)
639 render->render_target, render->filter);
640
641 device_state_restore(render->device, &render->previous_device_state);
642
643 render->state = CUBE_BEGIN;
644 }
645 else if (render->state != CUBE_BEGIN)
646 return D3DERR_INVALIDCALL;
647
648 device_state_capture(render->device, &render->previous_device_state);
649
650 for (i = 1; i < render->previous_device_state.num_render_targets; i++)
652
653 if (!render->render_target)
654 {
659 }
660 else hr = IDirect3DDevice9_SetRenderTarget(render->device, 0, render->render_target);
661
662 if (FAILED(hr)) goto cleanup;
663
664 hr = IDirect3DDevice9_SetDepthStencilSurface(render->device, render->depth_stencil);
665 if (FAILED(hr)) goto cleanup;
666
667 render->state = CUBE_FACE;
668 render->face = face;
669 render->filter = filter;
670 return IDirect3DDevice9_BeginScene(render->device);
671
672cleanup:
673 device_state_restore(render->device, &render->previous_device_state);
674 return hr;
675}
#define IDirect3DDevice9_BeginScene(p)
Definition: d3d9.h:1376
#define IDirect3DDevice9_SetRenderTarget(p, a, b)
Definition: d3d9.h:1372
#define IDirect3DDevice9_SetDepthStencilSurface(p, a)
Definition: d3d9.h:1374
WORD face[3]
Definition: mesh.c:4854
static void device_state_capture(IDirect3DDevice9 *device, struct device_state *state)
Definition: render.c:53
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
DWORD filter
Definition: render.c:439
IDirect3DSurface9 * render_target
Definition: render.c:441

◆ D3DXRenderToEnvMap_GetDesc()

static HRESULT WINAPI D3DXRenderToEnvMap_GetDesc ( ID3DXRenderToEnvMap *  iface,
D3DXRTE_DESC *  desc 
)
static

Definition at line 536 of file render.c.

538{
540
541 TRACE("iface %p, desc %p.\n", iface, desc);
542
543 if (!desc) return D3DERR_INVALIDCALL;
544
545 *desc = render->desc;
546 return D3D_OK;
547}
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683

◆ D3DXRenderToEnvMap_GetDevice()

static HRESULT WINAPI D3DXRenderToEnvMap_GetDevice ( ID3DXRenderToEnvMap *  iface,
IDirect3DDevice9 **  device 
)
static

Definition at line 522 of file render.c.

524{
526
527 TRACE("iface %p, device %p.\n", iface, device);
528
529 if (!device) return D3DERR_INVALIDCALL;
530
532 *device = render->device;
533 return D3D_OK;
534}

◆ D3DXRenderToEnvMap_OnLostDevice()

static HRESULT WINAPI D3DXRenderToEnvMap_OnLostDevice ( ID3DXRenderToEnvMap *  iface)
static

Definition at line 717 of file render.c.

718{
719 FIXME("iface %p stub!\n", iface);
720 return D3D_OK;
721}

◆ D3DXRenderToEnvMap_OnResetDevice()

static HRESULT WINAPI D3DXRenderToEnvMap_OnResetDevice ( ID3DXRenderToEnvMap *  iface)
static

Definition at line 723 of file render.c.

724{
725 FIXME("iface %p stub!\n", iface);
726 return D3D_OK;
727}

◆ D3DXRenderToEnvMap_QueryInterface()

static HRESULT WINAPI D3DXRenderToEnvMap_QueryInterface ( ID3DXRenderToEnvMap *  iface,
REFIID  riid,
void **  out 
)
static

Definition at line 467 of file render.c.

470{
471 TRACE("iface %p, riid %s, out %p\n", iface, debugstr_guid(riid), out);
472
473 if (IsEqualGUID(riid, &IID_ID3DXRenderToEnvMap)
475 {
476 IUnknown_AddRef(iface);
477 *out = iface;
478 return S_OK;
479 }
480
481 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
482
483 *out = NULL;
484 return E_NOINTERFACE;
485}
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ D3DXRenderToEnvMap_Release()

static ULONG WINAPI D3DXRenderToEnvMap_Release ( ID3DXRenderToEnvMap *  iface)
static

Definition at line 497 of file render.c.

498{
501
502 TRACE("%p decreasing refcount to %lu.\n", iface, ref);
503
504 if (!ref)
505 {
506 if (render->dst_cube_texture)
507 IDirect3DCubeTexture9_Release(render->dst_cube_texture);
508
509 if (render->render_target) IDirect3DSurface9_Release(render->render_target);
510 if (render->depth_stencil) IDirect3DSurface9_Release(render->depth_stencil);
511
512 device_state_release(&render->previous_device_state);
513
515
516 free(render);
517 }
518
519 return ref;
520}
#define InterlockedDecrement
Definition: armddk.h:52
#define IDirect3DDevice9_Release(p)
Definition: d3d9.h:1336
static void device_state_release(struct device_state *state)
Definition: render.c:92

◆ D3DXRenderToSurface_AddRef()

static ULONG WINAPI D3DXRenderToSurface_AddRef ( ID3DXRenderToSurface *  iface)
static

Definition at line 148 of file render.c.

149{
152
153 TRACE("%p increasing refcount to %lu.\n", iface, ref);
154
155 return ref;
156}
static struct render_to_surface * impl_from_ID3DXRenderToSurface(ID3DXRenderToSurface *iface)
Definition: render.c:123

◆ D3DXRenderToSurface_BeginScene()

static HRESULT WINAPI D3DXRenderToSurface_BeginScene ( ID3DXRenderToSurface *  iface,
IDirect3DSurface9 *  surface,
const D3DVIEWPORT9 *  viewport 
)
static

Definition at line 209 of file render.c.

212{
214 unsigned int i;
216 D3DSURFACE_DESC surface_desc;
218 D3DMULTISAMPLE_TYPE multi_sample_type = D3DMULTISAMPLE_NONE;
219 DWORD multi_sample_quality = 0;
220
221 TRACE("iface %p, surface %p, viewport %p.\n", iface, surface, viewport);
222
223 if (!surface || render->dst_surface) return D3DERR_INVALIDCALL;
224
225 IDirect3DSurface9_GetDesc(surface, &surface_desc);
226 if (surface_desc.Format != render->desc.Format
227 || surface_desc.Width != render->desc.Width
228 || surface_desc.Height != render->desc.Height)
229 return D3DERR_INVALIDCALL;
230
231 if (viewport)
232 {
233 if (viewport->X > render->desc.Width || viewport->Y > render->desc.Height
234 || viewport->X + viewport->Width > render->desc.Width
235 || viewport->Y + viewport->Height > render->desc.Height)
236 return D3DERR_INVALIDCALL;
237
238 if (!(surface_desc.Usage & D3DUSAGE_RENDERTARGET)
239 && (viewport->X != 0 || viewport->Y != 0
240 || viewport->Width != render->desc.Width
241 || viewport->Height != render->desc.Height))
242 return D3DERR_INVALIDCALL;
243 }
244
245 device = render->device;
246
247 device_state_capture(device, &render->previous_state);
248
249 /* prepare for rendering to surface */
250 for (i = 1; i < render->previous_state.num_render_targets; i++)
252
253 if (surface_desc.Usage & D3DUSAGE_RENDERTARGET)
254 {
256 multi_sample_type = surface_desc.MultiSampleType;
257 multi_sample_quality = surface_desc.MultiSampleQuality;
258 }
259 else
260 {
261 hr = IDirect3DDevice9_CreateRenderTarget(device, render->desc.Width, render->desc.Height,
262 render->desc.Format, multi_sample_type, multi_sample_quality, FALSE,
263 &render->render_target, NULL);
264 if (FAILED(hr)) goto cleanup;
265 hr = IDirect3DDevice9_SetRenderTarget(device, 0, render->render_target);
266 }
267
268 if (FAILED(hr)) goto cleanup;
269
270 if (render->desc.DepthStencil)
271 {
273 render->desc.DepthStencilFormat, multi_sample_type, multi_sample_quality, TRUE,
274 &render->depth_stencil, NULL);
275 }
276 else render->depth_stencil = NULL;
277
278 if (FAILED(hr)) goto cleanup;
279
281 if (FAILED(hr)) goto cleanup;
282
283 if (viewport) IDirect3DDevice9_SetViewport(device, viewport);
284
286 render->dst_surface = surface;
288
289cleanup:
290 device_state_restore(device, &render->previous_state);
291
292 if (render->dst_surface) IDirect3DSurface9_Release(render->dst_surface);
293 render->dst_surface = NULL;
294
295 if (render->render_target) IDirect3DSurface9_Release(render->render_target);
296 render->render_target = NULL;
297 if (render->depth_stencil) IDirect3DSurface9_Release(render->depth_stencil);
298 render->depth_stencil = NULL;
299
300 return hr;
301}
@ D3DMULTISAMPLE_NONE
Definition: d3d8types.h:672
enum _D3DMULTISAMPLE_TYPE D3DMULTISAMPLE_TYPE
#define IDirect3DDevice9_SetViewport(p, a)
Definition: d3d9.h:1382
#define IDirect3DSurface9_AddRef(p)
Definition: d3d9.h:449
#define IDirect3DSurface9_GetDesc(p, a)
Definition: d3d9.h:462
#define FALSE
Definition: types.h:117
DWORD IDirect3DDevice9
Definition: dxva2api.idl:22
unsigned long DWORD
Definition: ntddk_ex.h:95

◆ D3DXRenderToSurface_EndScene()

static HRESULT WINAPI D3DXRenderToSurface_EndScene ( ID3DXRenderToSurface *  iface,
DWORD  filter 
)
static

Definition at line 303 of file render.c.

305{
307 HRESULT hr;
308
309 TRACE("iface %p, filter %#lx.\n", iface, filter);
310
311 if (!render->dst_surface) return D3DERR_INVALIDCALL;
312
314
315 /* copy render target data to destination surface, if needed */
316 if (render->render_target)
317 {
319 render->render_target, NULL, NULL, filter, 0);
320 if (FAILED(hr))
321 ERR("Copying render target data to surface failed, hr %#lx.\n", hr);
322 }
323
324 device_state_restore(render->device, &render->previous_state);
325
326 /* release resources */
327 if (render->render_target)
328 {
329 IDirect3DSurface9_Release(render->render_target);
330 render->render_target = NULL;
331 }
332
333 if (render->depth_stencil)
334 {
335 IDirect3DSurface9_Release(render->depth_stencil);
336 render->depth_stencil = NULL;
337 }
338
339 IDirect3DSurface9_Release(render->dst_surface);
340 render->dst_surface = NULL;
341
342 return hr;
343}

◆ D3DXRenderToSurface_GetDesc()

static HRESULT WINAPI D3DXRenderToSurface_GetDesc ( ID3DXRenderToSurface *  iface,
D3DXRTS_DESC *  desc 
)
static

Definition at line 196 of file render.c.

198{
200
201 TRACE("iface %p, desc %p.\n", iface, desc);
202
203 if (!desc) return D3DERR_INVALIDCALL;
204
205 *desc = render->desc;
206 return D3D_OK;
207}

◆ D3DXRenderToSurface_GetDevice()

static HRESULT WINAPI D3DXRenderToSurface_GetDevice ( ID3DXRenderToSurface *  iface,
IDirect3DDevice9 **  device 
)
static

Definition at line 182 of file render.c.

184{
186
187 TRACE("iface %p, device %p.\n", iface, device);
188
189 if (!device) return D3DERR_INVALIDCALL;
190
192 *device = render->device;
193 return D3D_OK;
194}

◆ D3DXRenderToSurface_OnLostDevice()

static HRESULT WINAPI D3DXRenderToSurface_OnLostDevice ( ID3DXRenderToSurface *  iface)
static

Definition at line 345 of file render.c.

346{
347 FIXME("iface %p stub!\n", iface);
348 return D3D_OK;
349}

◆ D3DXRenderToSurface_OnResetDevice()

static HRESULT WINAPI D3DXRenderToSurface_OnResetDevice ( ID3DXRenderToSurface *  iface)
static

Definition at line 351 of file render.c.

352{
353 FIXME("iface %p stub!\n", iface);
354 return D3D_OK;
355}

◆ D3DXRenderToSurface_QueryInterface()

static HRESULT WINAPI D3DXRenderToSurface_QueryInterface ( ID3DXRenderToSurface *  iface,
REFIID  riid,
void **  out 
)
static

Definition at line 128 of file render.c.

131{
132 TRACE("iface %p, riid %s, out %p\n", iface, debugstr_guid(riid), out);
133
134 if (IsEqualGUID(riid, &IID_ID3DXRenderToSurface)
136 {
137 IUnknown_AddRef(iface);
138 *out = iface;
139 return S_OK;
140 }
141
142 WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
143
144 *out = NULL;
145 return E_NOINTERFACE;
146}

◆ D3DXRenderToSurface_Release()

static ULONG WINAPI D3DXRenderToSurface_Release ( ID3DXRenderToSurface *  iface)
static

Definition at line 158 of file render.c.

159{
162
163 TRACE("%p decreasing refcount to %lu.\n", iface, ref);
164
165 if (!ref)
166 {
167 if (render->dst_surface) IDirect3DSurface9_Release(render->dst_surface);
168
169 if (render->render_target) IDirect3DSurface9_Release(render->render_target);
170 if (render->depth_stencil) IDirect3DSurface9_Release(render->depth_stencil);
171
172 device_state_release(&render->previous_state);
173
175
176 free(render);
177 }
178
179 return ref;
180}

◆ device_state_capture()

static void device_state_capture ( IDirect3DDevice9 *  device,
struct device_state *  state 
)
static

Definition at line 53 of file render.c.

54{
55 HRESULT hr;
56 unsigned int i;
57
59
60 for (i = 0; i < state->num_render_targets; i++)
61 {
62 hr = IDirect3DDevice9_GetRenderTarget(device, i, &state->render_targets[i]);
63 if (FAILED(hr)) state->render_targets[i] = NULL;
64 }
65
67 if (FAILED(hr)) state->depth_stencil = NULL;
68}
static int state
Definition: maze.c:121
#define IDirect3DDevice9_GetViewport(p, a)
Definition: d3d9.h:1383
#define IDirect3DDevice9_GetDepthStencilSurface(p, a)
Definition: d3d9.h:1375
#define IDirect3DDevice9_GetRenderTarget(p, a, b)
Definition: d3d9.h:1373

Referenced by D3DXRenderToEnvMap_Face(), and D3DXRenderToSurface_BeginScene().

◆ device_state_init()

static HRESULT device_state_init ( IDirect3DDevice9 *  device,
struct device_state *  state 
)
static

Definition at line 33 of file render.c.

34{
35 HRESULT hr;
36 D3DCAPS9 caps;
37 unsigned int i;
38
40 if (FAILED(hr)) return hr;
41
42 state->num_render_targets = caps.NumSimultaneousRTs;
43 state->render_targets = malloc(state->num_render_targets * sizeof(IDirect3DSurface9 *));
44 if (!state->render_targets)
45 return E_OUTOFMEMORY;
46
47 for (i = 0; i < state->num_render_targets; i++)
48 state->render_targets[i] = NULL;
49 state->depth_stencil = NULL;
50 return D3D_OK;
51}
#define IDirect3DDevice9_GetDeviceCaps(p, a)
Definition: d3d9.h:1342
DWORD NumSimultaneousRTs
Definition: d3d9caps.h:324

Referenced by D3DXCreateRenderToEnvMap(), and D3DXCreateRenderToSurface().

◆ device_state_release()

static void device_state_release ( struct device_state *  state)
static

Definition at line 92 of file render.c.

93{
94 unsigned int i;
95
96 for (i = 0; i < state->num_render_targets; i++)
97 {
98 if (state->render_targets[i])
99 IDirect3DSurface9_Release(state->render_targets[i]);
100 }
101
102 free(state->render_targets);
103
104 if (state->depth_stencil) IDirect3DSurface9_Release(state->depth_stencil);
105}

Referenced by D3DXRenderToEnvMap_Release(), and D3DXRenderToSurface_Release().

◆ device_state_restore()

static void device_state_restore ( IDirect3DDevice9 *  device,
struct device_state *  state 
)
static

Definition at line 70 of file render.c.

71{
72 unsigned int i;
73
74 for (i = 0; i < state->num_render_targets; i++)
75 {
77 if (state->render_targets[i])
78 IDirect3DSurface9_Release(state->render_targets[i]);
79 state->render_targets[i] = NULL;
80 }
81
83 if (state->depth_stencil)
84 {
85 IDirect3DSurface9_Release(state->depth_stencil);
86 state->depth_stencil = NULL;
87 }
88
90}

Referenced by D3DXRenderToEnvMap_End(), D3DXRenderToEnvMap_Face(), D3DXRenderToSurface_BeginScene(), and D3DXRenderToSurface_EndScene().

◆ impl_from_ID3DXRenderToEnvMap()

static struct render_to_envmap * impl_from_ID3DXRenderToEnvMap ( ID3DXRenderToEnvMap *  iface)
inlinestatic

Definition at line 462 of file render.c.

463{
464 return CONTAINING_RECORD(iface, struct render_to_envmap, ID3DXRenderToEnvMap_iface);
465}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by D3DXRenderToEnvMap_AddRef(), D3DXRenderToEnvMap_BeginCube(), D3DXRenderToEnvMap_End(), D3DXRenderToEnvMap_Face(), D3DXRenderToEnvMap_GetDesc(), D3DXRenderToEnvMap_GetDevice(), and D3DXRenderToEnvMap_Release().

◆ impl_from_ID3DXRenderToSurface()

static struct render_to_surface * impl_from_ID3DXRenderToSurface ( ID3DXRenderToSurface *  iface)
inlinestatic

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3dx  )

Variable Documentation

◆ render_to_envmap_vtbl

const ID3DXRenderToEnvMapVtbl render_to_envmap_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI D3DXRenderToEnvMap_OnLostDevice(ID3DXRenderToEnvMap *iface)
Definition: render.c:717
static HRESULT WINAPI D3DXRenderToEnvMap_Face(ID3DXRenderToEnvMap *iface, D3DCUBEMAP_FACES face, DWORD filter)
Definition: render.c:624
static HRESULT WINAPI D3DXRenderToEnvMap_BeginHemisphere(ID3DXRenderToEnvMap *iface, IDirect3DTexture9 *pos_z_texture, IDirect3DTexture9 *neg_z_texture)
Definition: render.c:608
static HRESULT WINAPI D3DXRenderToEnvMap_BeginParabolic(ID3DXRenderToEnvMap *iface, IDirect3DTexture9 *pos_z_texture, IDirect3DTexture9 *neg_z_texture)
Definition: render.c:616
static HRESULT WINAPI D3DXRenderToEnvMap_GetDesc(ID3DXRenderToEnvMap *iface, D3DXRTE_DESC *desc)
Definition: render.c:536
static ULONG WINAPI D3DXRenderToEnvMap_AddRef(ID3DXRenderToEnvMap *iface)
Definition: render.c:487
static ULONG WINAPI D3DXRenderToEnvMap_Release(ID3DXRenderToEnvMap *iface)
Definition: render.c:497
static HRESULT WINAPI D3DXRenderToEnvMap_QueryInterface(ID3DXRenderToEnvMap *iface, REFIID riid, void **out)
Definition: render.c:467
static HRESULT WINAPI D3DXRenderToEnvMap_GetDevice(ID3DXRenderToEnvMap *iface, IDirect3DDevice9 **device)
Definition: render.c:522
static HRESULT WINAPI D3DXRenderToEnvMap_End(ID3DXRenderToEnvMap *iface, DWORD filter)
Definition: render.c:677
static HRESULT WINAPI D3DXRenderToEnvMap_BeginSphere(ID3DXRenderToEnvMap *iface, IDirect3DTexture9 *texture)
Definition: render.c:601
static HRESULT WINAPI D3DXRenderToEnvMap_BeginCube(ID3DXRenderToEnvMap *iface, IDirect3DCubeTexture9 *texture)
Definition: render.c:549
static HRESULT WINAPI D3DXRenderToEnvMap_OnResetDevice(ID3DXRenderToEnvMap *iface)
Definition: render.c:723

Definition at line 729 of file render.c.

Referenced by D3DXCreateRenderToEnvMap().

◆ render_to_surface_vtbl

const ID3DXRenderToSurfaceVtbl render_to_surface_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI D3DXRenderToSurface_OnLostDevice(ID3DXRenderToSurface *iface)
Definition: render.c:345
static HRESULT WINAPI D3DXRenderToSurface_BeginScene(ID3DXRenderToSurface *iface, IDirect3DSurface9 *surface, const D3DVIEWPORT9 *viewport)
Definition: render.c:209
static ULONG WINAPI D3DXRenderToSurface_Release(ID3DXRenderToSurface *iface)
Definition: render.c:158
static HRESULT WINAPI D3DXRenderToSurface_EndScene(ID3DXRenderToSurface *iface, DWORD filter)
Definition: render.c:303
static HRESULT WINAPI D3DXRenderToSurface_OnResetDevice(ID3DXRenderToSurface *iface)
Definition: render.c:351
static ULONG WINAPI D3DXRenderToSurface_AddRef(ID3DXRenderToSurface *iface)
Definition: render.c:148
static HRESULT WINAPI D3DXRenderToSurface_GetDevice(ID3DXRenderToSurface *iface, IDirect3DDevice9 **device)
Definition: render.c:182
static HRESULT WINAPI D3DXRenderToSurface_QueryInterface(ID3DXRenderToSurface *iface, REFIID riid, void **out)
Definition: render.c:128
static HRESULT WINAPI D3DXRenderToSurface_GetDesc(ID3DXRenderToSurface *iface, D3DXRTS_DESC *desc)
Definition: render.c:196

Definition at line 357 of file render.c.

Referenced by D3DXCreateRenderToSurface().