~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to src/gallium/frontends/nine/surface9.h

  • Committer: mmach
  • Date: 2022-09-22 19:56:13 UTC
  • Revision ID: netbit73@gmail.com-20220922195613-wtik9mmy20tmor0i
2022-09-22 21:17:09

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright 2011 Joakim Sindholt <opensource@zhasha.com>
3
 
 *
4
 
 * Permission is hereby granted, free of charge, to any person obtaining a
5
 
 * copy of this software and associated documentation files (the "Software"),
6
 
 * to deal in the Software without restriction, including without limitation
7
 
 * on the rights to use, copy, modify, merge, publish, distribute, sub
8
 
 * license, and/or sell copies of the Software, and to permit persons to whom
9
 
 * the Software is furnished to do so, subject to the following conditions:
10
 
 *
11
 
 * The above copyright notice and this permission notice (including the next
12
 
 * paragraph) shall be included in all copies or substantial portions of the
13
 
 * Software.
14
 
 *
15
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18
 
 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19
 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20
 
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21
 
 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
22
 
 
23
 
#ifndef _NINE_SURFACE9_H_
24
 
#define _NINE_SURFACE9_H_
25
 
 
26
 
#include "nine_memory_helper.h"
27
 
#include "resource9.h"
28
 
 
29
 
#include "pipe/p_state.h"
30
 
#include "util/list.h"
31
 
#include "util/u_rect.h"
32
 
#include "util/u_inlines.h"
33
 
 
34
 
struct NineSurface9
35
 
{
36
 
    struct NineResource9 base;
37
 
 
38
 
    /* G3D state */
39
 
    struct pipe_transfer *transfer;
40
 
    struct pipe_surface *surface[2]; /* created on-demand (linear, sRGB) */
41
 
    int lock_count;
42
 
    uint8_t texture; /* rtype of container BaseTex or 0 */
43
 
 
44
 
    /* resource description */
45
 
    unsigned level;        /* refers to the pipe_resource (SetLOD !) */
46
 
    unsigned level_actual; /* refers to the NineTexture */
47
 
    unsigned layer;
48
 
    D3DSURFACE_DESC desc;
49
 
 
50
 
    struct nine_allocation *data; /* system memory backing */
51
 
    struct nine_allocation *data_internal; /* for conversions */
52
 
    enum pipe_format format_internal;
53
 
    unsigned stride; /* for system memory backing */
54
 
    unsigned stride_internal;
55
 
 
56
 
    unsigned pending_uploads_counter; /* pending uploads */
57
 
};
58
 
static inline struct NineSurface9 *
59
 
NineSurface9( void *data )
60
 
{
61
 
    return (struct NineSurface9 *)data;
62
 
}
63
 
 
64
 
HRESULT
65
 
NineSurface9_new( struct NineDevice9 *pDevice,
66
 
                  struct NineUnknown *pContainer,
67
 
                  struct pipe_resource *pResource,
68
 
                  struct nine_allocation *user_buffer,
69
 
                  uint8_t TextureType, /* 0 if pContainer isn't BaseTexure9 */
70
 
                  unsigned Level,
71
 
                  unsigned Layer,
72
 
                  D3DSURFACE_DESC *pDesc,
73
 
                  struct NineSurface9 **ppOut );
74
 
 
75
 
HRESULT
76
 
NineSurface9_ctor( struct NineSurface9 *This,
77
 
                   struct NineUnknownParams *pParams,
78
 
                   struct NineUnknown *pContainer,
79
 
                   struct pipe_resource *pResource,
80
 
                   struct nine_allocation *user_buffer,
81
 
                   uint8_t TextureType,
82
 
                   unsigned Level,
83
 
                   unsigned Layer,
84
 
                   D3DSURFACE_DESC *pDesc );
85
 
 
86
 
void
87
 
NineSurface9_dtor( struct NineSurface9 *This );
88
 
 
89
 
/*** Nine private ***/
90
 
 
91
 
void
92
 
NineSurface9_MarkContainerDirty( struct NineSurface9 *This );
93
 
 
94
 
static inline struct pipe_surface *
95
 
NineSurface9_GetSurface( struct NineSurface9 *This, int sRGB )
96
 
{
97
 
    assert(This->surface[sRGB]);
98
 
    return This->surface[sRGB];
99
 
}
100
 
 
101
 
static inline struct pipe_resource *
102
 
NineSurface9_GetResource( struct NineSurface9 *This )
103
 
{
104
 
    return This->base.resource;
105
 
}
106
 
 
107
 
void
108
 
NineSurface9_SetResource( struct NineSurface9 *This,
109
 
                          struct pipe_resource *resource, unsigned level );
110
 
 
111
 
void
112
 
NineSurface9_SetMultiSampleType( struct NineSurface9 *This,
113
 
                                 D3DMULTISAMPLE_TYPE mst );
114
 
 
115
 
void
116
 
NineSurface9_SetResourceResize( struct NineSurface9 *This,
117
 
                                struct pipe_resource *resource );
118
 
 
119
 
void
120
 
NineSurface9_AddDirtyRect( struct NineSurface9 *This,
121
 
                           const struct pipe_box *box );
122
 
 
123
 
HRESULT
124
 
NineSurface9_UploadSelf( struct NineSurface9 *This,
125
 
                         const struct pipe_box *damaged );
126
 
 
127
 
void
128
 
NineSurface9_CopyMemToDefault( struct NineSurface9 *This,
129
 
                               struct NineSurface9 *From,
130
 
                               const POINT *pDestPoint,
131
 
                               const RECT *pSourceRect );
132
 
 
133
 
void
134
 
NineSurface9_CopyDefaultToMem( struct NineSurface9 *This,
135
 
                               struct NineSurface9 *From );
136
 
 
137
 
static inline boolean
138
 
NineSurface9_IsOffscreenPlain (struct NineSurface9 *This )
139
 
{
140
 
    return This->base.usage == 0 && !This->texture;
141
 
}
142
 
 
143
 
#if defined(DEBUG) || !defined(NDEBUG)
144
 
void
145
 
NineSurface9_Dump( struct NineSurface9 *This );
146
 
#else
147
 
static inline void
148
 
NineSurface9_Dump( struct NineSurface9 *This ) { }
149
 
#endif
150
 
 
151
 
/*** Direct3D public ***/
152
 
 
153
 
HRESULT NINE_WINAPI
154
 
NineSurface9_GetContainer( struct NineSurface9 *This,
155
 
                           REFIID riid,
156
 
                           void **ppContainer );
157
 
 
158
 
HRESULT NINE_WINAPI
159
 
NineSurface9_GetDesc( struct NineSurface9 *This,
160
 
                      D3DSURFACE_DESC *pDesc );
161
 
 
162
 
HRESULT NINE_WINAPI
163
 
NineSurface9_LockRect( struct NineSurface9 *This,
164
 
                       D3DLOCKED_RECT *pLockedRect,
165
 
                       const RECT *pRect,
166
 
                       DWORD Flags );
167
 
 
168
 
HRESULT NINE_WINAPI
169
 
NineSurface9_UnlockRect( struct NineSurface9 *This );
170
 
 
171
 
HRESULT NINE_WINAPI
172
 
NineSurface9_GetDC( struct NineSurface9 *This,
173
 
                    HDC *phdc );
174
 
 
175
 
HRESULT NINE_WINAPI
176
 
NineSurface9_ReleaseDC( struct NineSurface9 *This,
177
 
                        HDC hdc );
178
 
 
179
 
#endif /* _NINE_SURFACE9_H_ */