rapidshot 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rapidshot/__init__.py +406 -0
- rapidshot/_libs/__init__.py +0 -0
- rapidshot/_libs/d3d11.py +270 -0
- rapidshot/_libs/dxgi.py +281 -0
- rapidshot/_libs/user32.py +28 -0
- rapidshot/core/__init__.py +7 -0
- rapidshot/core/device.py +81 -0
- rapidshot/core/duplicator.py +277 -0
- rapidshot/core/output.py +60 -0
- rapidshot/core/stagesurf.py +123 -0
- rapidshot/core.py +557 -0
- rapidshot/processor/__init__.py +1 -0
- rapidshot/processor/base.py +154 -0
- rapidshot/processor/cupy_processor.py +279 -0
- rapidshot/processor/numpy_processor.py +138 -0
- rapidshot/processor/pillow_processor.py +106 -0
- rapidshot/util/__init__.py +0 -0
- rapidshot/util/io.py +94 -0
- rapidshot/util/logging.py +128 -0
- rapidshot/util/timer.py +39 -0
- rapidshot-1.0.0.dist-info/METADATA +409 -0
- rapidshot-1.0.0.dist-info/RECORD +25 -0
- rapidshot-1.0.0.dist-info/WHEEL +5 -0
- rapidshot-1.0.0.dist-info/licenses/LICENSE +21 -0
- rapidshot-1.0.0.dist-info/top_level.txt +1 -0
rapidshot/__init__.py
ADDED
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import weakref
|
|
2
|
+
import time
|
|
3
|
+
import logging
|
|
4
|
+
import platform
|
|
5
|
+
import sys
|
|
6
|
+
from typing import Optional, Tuple, Dict, Any
|
|
7
|
+
from rapidshot.core import ScreenCapture
|
|
8
|
+
from rapidshot.core import Output, Device
|
|
9
|
+
from rapidshot.util.io import (
|
|
10
|
+
enum_dxgi_adapters,
|
|
11
|
+
get_output_metadata,
|
|
12
|
+
)
|
|
13
|
+
from rapidshot.util.logging import setup_logging, get_logger
|
|
14
|
+
|
|
15
|
+
# Initialize logging
|
|
16
|
+
logger = get_logger("init")
|
|
17
|
+
|
|
18
|
+
# Define explicitly what's exposed from this module
|
|
19
|
+
__all__ = [
|
|
20
|
+
"create", "device_info", "output_info",
|
|
21
|
+
"clean_up", "reset", "ScreenCapture",
|
|
22
|
+
"RapidshotError", "get_version_info"
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
class RapidshotError(Exception):
|
|
26
|
+
"""Base exception for Rapidshot errors."""
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class DeviceError(RapidshotError):
|
|
31
|
+
"""Exception raised for errors related to device operations."""
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class OutputError(RapidshotError):
|
|
36
|
+
"""Exception raised for errors related to output operations."""
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class ConfigurationError(RapidshotError):
|
|
41
|
+
"""Exception raised for errors related to configuration."""
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class Singleton(type):
|
|
46
|
+
"""
|
|
47
|
+
Singleton metaclass to ensure only one instance of RapidshotFactory exists.
|
|
48
|
+
"""
|
|
49
|
+
_instances = {}
|
|
50
|
+
|
|
51
|
+
def __call__(cls, *args, **kwargs):
|
|
52
|
+
if cls not in cls._instances:
|
|
53
|
+
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
|
|
54
|
+
else:
|
|
55
|
+
logger.debug(f"Using existing instance of {cls.__name__}")
|
|
56
|
+
return cls._instances[cls]
|
|
57
|
+
|
|
58
|
+
class RapidshotFactory(metaclass=Singleton):
|
|
59
|
+
"""
|
|
60
|
+
Factory class for creating ScreenCapture instances.
|
|
61
|
+
Maintains a registry of created screencapture instances to avoid duplicates.
|
|
62
|
+
"""
|
|
63
|
+
_screencapture_instances = weakref.WeakValueDictionary()
|
|
64
|
+
|
|
65
|
+
def __init__(self) -> None:
|
|
66
|
+
"""
|
|
67
|
+
Initialize the factory by enumerating all available devices and outputs.
|
|
68
|
+
"""
|
|
69
|
+
logger.info("Initializing RapidshotFactory")
|
|
70
|
+
try:
|
|
71
|
+
p_adapters = enum_dxgi_adapters()
|
|
72
|
+
if not p_adapters:
|
|
73
|
+
error_msg = "No DXGI adapters found. Make sure your system has a compatible graphics card."
|
|
74
|
+
logger.error(error_msg)
|
|
75
|
+
raise DeviceError(error_msg)
|
|
76
|
+
|
|
77
|
+
self.devices, self.outputs = [], []
|
|
78
|
+
|
|
79
|
+
for p_adapter in p_adapters:
|
|
80
|
+
try:
|
|
81
|
+
device = Device(p_adapter)
|
|
82
|
+
p_outputs = device.enum_outputs()
|
|
83
|
+
if len(p_outputs) != 0:
|
|
84
|
+
self.devices.append(device)
|
|
85
|
+
self.outputs.append([Output(p_output) for p_output in p_outputs])
|
|
86
|
+
except Exception as e:
|
|
87
|
+
logger.warning(f"Failed to initialize device: {e}")
|
|
88
|
+
|
|
89
|
+
if not self.devices:
|
|
90
|
+
error_msg = "No usable graphics devices found. Check your display configuration."
|
|
91
|
+
logger.error(error_msg)
|
|
92
|
+
raise DeviceError(error_msg)
|
|
93
|
+
|
|
94
|
+
self.output_metadata = get_output_metadata()
|
|
95
|
+
logger.info(f"RapidshotFactory initialized with {len(self.devices)} devices")
|
|
96
|
+
except Exception as e:
|
|
97
|
+
error_msg = f"Failed to initialize RapidshotFactory: {e}"
|
|
98
|
+
logger.error(error_msg)
|
|
99
|
+
raise RapidshotError(error_msg) from e
|
|
100
|
+
|
|
101
|
+
def create(
|
|
102
|
+
self,
|
|
103
|
+
device_idx: int = 0,
|
|
104
|
+
output_idx: int = None,
|
|
105
|
+
region: tuple = None,
|
|
106
|
+
output_color: str = "RGB",
|
|
107
|
+
nvidia_gpu: bool = False,
|
|
108
|
+
max_buffer_len: int = 64,
|
|
109
|
+
):
|
|
110
|
+
"""
|
|
111
|
+
Create a ScreenCapture instance.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
device_idx: Device index
|
|
115
|
+
output_idx: Output index (None for primary)
|
|
116
|
+
region: Region to capture (left, top, right, bottom)
|
|
117
|
+
output_color: Color format (RGB, RGBA, BGR, BGRA, GRAY)
|
|
118
|
+
nvidia_gpu: Whether to use NVIDIA GPU acceleration
|
|
119
|
+
max_buffer_len: Maximum buffer length for capture
|
|
120
|
+
|
|
121
|
+
Returns:
|
|
122
|
+
ScreenCapture instance
|
|
123
|
+
"""
|
|
124
|
+
logger.debug(f"Creating ScreenCapture with device_idx={device_idx}, output_idx={output_idx}, nvidia_gpu={nvidia_gpu}")
|
|
125
|
+
|
|
126
|
+
# Validate device index
|
|
127
|
+
if device_idx >= len(self.devices):
|
|
128
|
+
error_msg = f"Invalid device index: {device_idx}, max index is {len(self.devices)-1}"
|
|
129
|
+
logger.error(error_msg)
|
|
130
|
+
raise DeviceError(error_msg)
|
|
131
|
+
|
|
132
|
+
device = self.devices[device_idx]
|
|
133
|
+
|
|
134
|
+
# Auto-select primary output if not specified
|
|
135
|
+
if output_idx is None:
|
|
136
|
+
output_idx_list = []
|
|
137
|
+
for idx, output in enumerate(self.outputs[device_idx]):
|
|
138
|
+
metadata = self.output_metadata.get(output.devicename)
|
|
139
|
+
if metadata and metadata[1]: # Is primary
|
|
140
|
+
output_idx_list.append(idx)
|
|
141
|
+
|
|
142
|
+
if not output_idx_list:
|
|
143
|
+
# No primary monitor found, use the first one
|
|
144
|
+
output_idx = 0
|
|
145
|
+
logger.info("No primary monitor found, using first available output.")
|
|
146
|
+
else:
|
|
147
|
+
output_idx = output_idx_list[0]
|
|
148
|
+
logger.info(f"Using primary monitor (output index {output_idx})")
|
|
149
|
+
elif output_idx >= len(self.outputs[device_idx]):
|
|
150
|
+
error_msg = f"Invalid output index: {output_idx}, max index is {len(self.outputs[device_idx])-1}"
|
|
151
|
+
logger.error(error_msg)
|
|
152
|
+
raise OutputError(error_msg)
|
|
153
|
+
|
|
154
|
+
# Validate color format
|
|
155
|
+
valid_color_formats = ["RGB", "RGBA", "BGR", "BGRA", "GRAY"]
|
|
156
|
+
if output_color not in valid_color_formats:
|
|
157
|
+
error_msg = f"Invalid color format: {output_color}. Must be one of {valid_color_formats}"
|
|
158
|
+
logger.error(error_msg)
|
|
159
|
+
raise ConfigurationError(error_msg)
|
|
160
|
+
|
|
161
|
+
# Check if instance already exists
|
|
162
|
+
instance_key = (device_idx, output_idx)
|
|
163
|
+
if instance_key in self._screencapture_instances:
|
|
164
|
+
logger.info(f"Found existing ScreenCapture instance for Device {device_idx}--Output {output_idx}")
|
|
165
|
+
return self._screencapture_instances[instance_key]
|
|
166
|
+
|
|
167
|
+
try:
|
|
168
|
+
# Create new instance
|
|
169
|
+
output = self.outputs[device_idx][output_idx]
|
|
170
|
+
output.update_desc()
|
|
171
|
+
|
|
172
|
+
if nvidia_gpu:
|
|
173
|
+
# Check if NVIDIA GPU is requested but not available
|
|
174
|
+
try:
|
|
175
|
+
import cupy
|
|
176
|
+
logger.info("Using NVIDIA GPU acceleration with CuPy")
|
|
177
|
+
except ImportError:
|
|
178
|
+
nvidia_gpu = False
|
|
179
|
+
logger.warning("NVIDIA GPU acceleration requested but CuPy not available. Falling back to CPU mode.")
|
|
180
|
+
|
|
181
|
+
screencapture = ScreenCapture(
|
|
182
|
+
output=output,
|
|
183
|
+
device=device,
|
|
184
|
+
region=region,
|
|
185
|
+
output_color=output_color,
|
|
186
|
+
nvidia_gpu=nvidia_gpu,
|
|
187
|
+
max_buffer_len=max_buffer_len,
|
|
188
|
+
)
|
|
189
|
+
self._screencapture_instances[instance_key] = screencapture
|
|
190
|
+
|
|
191
|
+
# Small delay to ensure initialization is complete
|
|
192
|
+
time.sleep(0.1)
|
|
193
|
+
logger.info(f"Created new ScreenCapture instance for Device {device_idx}--Output {output_idx}")
|
|
194
|
+
return screencapture
|
|
195
|
+
except Exception as e:
|
|
196
|
+
error_msg = f"Failed to create ScreenCapture instance: {e}"
|
|
197
|
+
logger.error(error_msg)
|
|
198
|
+
raise RapidshotError(error_msg) from e
|
|
199
|
+
|
|
200
|
+
def device_info(self) -> str:
|
|
201
|
+
"""
|
|
202
|
+
Get information about available devices.
|
|
203
|
+
|
|
204
|
+
Returns:
|
|
205
|
+
String with device information
|
|
206
|
+
"""
|
|
207
|
+
ret = ""
|
|
208
|
+
for idx, device in enumerate(self.devices):
|
|
209
|
+
ret += f"Device[{idx}]:{device}\n"
|
|
210
|
+
return ret
|
|
211
|
+
|
|
212
|
+
def output_info(self) -> str:
|
|
213
|
+
"""
|
|
214
|
+
Get information about available outputs.
|
|
215
|
+
|
|
216
|
+
Returns:
|
|
217
|
+
String with output information
|
|
218
|
+
"""
|
|
219
|
+
ret = ""
|
|
220
|
+
for didx, outputs in enumerate(self.outputs):
|
|
221
|
+
for idx, output in enumerate(outputs):
|
|
222
|
+
ret += f"Device[{didx}] Output[{idx}]: "
|
|
223
|
+
ret += f"Resolution:{output.resolution} Rotation:{output.rotation_angle} "
|
|
224
|
+
ret += f"Primary:{self.output_metadata.get(output.devicename)[1]}\n"
|
|
225
|
+
return ret
|
|
226
|
+
|
|
227
|
+
def clean_up(self):
|
|
228
|
+
"""
|
|
229
|
+
Release all created screencapture instances.
|
|
230
|
+
"""
|
|
231
|
+
logger.info("Cleaning up all ScreenCapture instances")
|
|
232
|
+
for _, screencapture in self._screencapture_instances.items():
|
|
233
|
+
try:
|
|
234
|
+
screencapture.release()
|
|
235
|
+
except Exception as e:
|
|
236
|
+
logger.warning(f"Error releasing ScreenCapture instance: {e}")
|
|
237
|
+
|
|
238
|
+
def reset(self):
|
|
239
|
+
"""
|
|
240
|
+
Reset the factory, releasing all resources.
|
|
241
|
+
"""
|
|
242
|
+
logger.info("Resetting RapidshotFactory")
|
|
243
|
+
self.clean_up()
|
|
244
|
+
self._screencapture_instances.clear()
|
|
245
|
+
Singleton._instances.clear()
|
|
246
|
+
|
|
247
|
+
# Global factory instance
|
|
248
|
+
__factory = None
|
|
249
|
+
|
|
250
|
+
def get_factory():
|
|
251
|
+
"""
|
|
252
|
+
Get the global factory instance, initializing it if necessary.
|
|
253
|
+
|
|
254
|
+
Returns:
|
|
255
|
+
RapidshotFactory instance
|
|
256
|
+
"""
|
|
257
|
+
global __factory
|
|
258
|
+
if __factory is None:
|
|
259
|
+
try:
|
|
260
|
+
__factory = RapidshotFactory()
|
|
261
|
+
except Exception as e:
|
|
262
|
+
logger.error(f"Failed to initialize RapidshotFactory: {e}")
|
|
263
|
+
raise
|
|
264
|
+
return __factory
|
|
265
|
+
|
|
266
|
+
def create(
|
|
267
|
+
device_idx: int = 0,
|
|
268
|
+
output_idx: int = None,
|
|
269
|
+
region: tuple = None,
|
|
270
|
+
output_color: str = "RGB",
|
|
271
|
+
nvidia_gpu: bool = False,
|
|
272
|
+
max_buffer_len: int = 64,
|
|
273
|
+
):
|
|
274
|
+
"""
|
|
275
|
+
Create a ScreenCapture instance.
|
|
276
|
+
|
|
277
|
+
Args:
|
|
278
|
+
device_idx: Device index
|
|
279
|
+
output_idx: Output index (None for primary)
|
|
280
|
+
region: Region to capture (left, top, right, bottom)
|
|
281
|
+
output_color: Color format (RGB, RGBA, BGR, BGRA, GRAY)
|
|
282
|
+
nvidia_gpu: Whether to use NVIDIA GPU acceleration
|
|
283
|
+
max_buffer_len: Maximum buffer length for capture
|
|
284
|
+
|
|
285
|
+
Returns:
|
|
286
|
+
ScreenCapture instance
|
|
287
|
+
"""
|
|
288
|
+
factory = get_factory()
|
|
289
|
+
return factory.create(
|
|
290
|
+
device_idx=device_idx,
|
|
291
|
+
output_idx=output_idx,
|
|
292
|
+
region=region,
|
|
293
|
+
output_color=output_color,
|
|
294
|
+
nvidia_gpu=nvidia_gpu,
|
|
295
|
+
max_buffer_len=max_buffer_len,
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
def device_info():
|
|
299
|
+
"""
|
|
300
|
+
Get information about available devices.
|
|
301
|
+
|
|
302
|
+
Returns:
|
|
303
|
+
String with device information
|
|
304
|
+
"""
|
|
305
|
+
factory = get_factory()
|
|
306
|
+
return factory.device_info()
|
|
307
|
+
|
|
308
|
+
def output_info():
|
|
309
|
+
"""
|
|
310
|
+
Get information about available outputs.
|
|
311
|
+
|
|
312
|
+
Returns:
|
|
313
|
+
String with output information
|
|
314
|
+
"""
|
|
315
|
+
factory = get_factory()
|
|
316
|
+
return factory.output_info()
|
|
317
|
+
|
|
318
|
+
def clean_up():
|
|
319
|
+
"""
|
|
320
|
+
Release all created screencapture instances.
|
|
321
|
+
"""
|
|
322
|
+
global __factory
|
|
323
|
+
if __factory is not None:
|
|
324
|
+
__factory.clean_up()
|
|
325
|
+
|
|
326
|
+
def reset():
|
|
327
|
+
"""
|
|
328
|
+
Reset the library, releasing all resources.
|
|
329
|
+
"""
|
|
330
|
+
global __factory
|
|
331
|
+
if __factory is not None:
|
|
332
|
+
__factory.reset()
|
|
333
|
+
__factory = None
|
|
334
|
+
|
|
335
|
+
def get_version_info() -> Dict[str, Any]:
|
|
336
|
+
"""
|
|
337
|
+
Get version information about RapidShot and its dependencies.
|
|
338
|
+
|
|
339
|
+
Returns:
|
|
340
|
+
Dictionary with version information
|
|
341
|
+
"""
|
|
342
|
+
info = {
|
|
343
|
+
"rapidshot": {
|
|
344
|
+
"version": __version__,
|
|
345
|
+
"author": __author__,
|
|
346
|
+
"description": __description__,
|
|
347
|
+
},
|
|
348
|
+
"system": {
|
|
349
|
+
"python": sys.version,
|
|
350
|
+
"platform": platform.platform(),
|
|
351
|
+
"processor": platform.processor(),
|
|
352
|
+
},
|
|
353
|
+
"dependencies": {}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
# Check numpy
|
|
357
|
+
try:
|
|
358
|
+
import numpy
|
|
359
|
+
info["dependencies"]["numpy"] = numpy.__version__
|
|
360
|
+
except ImportError:
|
|
361
|
+
info["dependencies"]["numpy"] = "not installed"
|
|
362
|
+
|
|
363
|
+
# Check cupy
|
|
364
|
+
try:
|
|
365
|
+
import cupy
|
|
366
|
+
info["dependencies"]["cupy"] = cupy.__version__
|
|
367
|
+
except ImportError:
|
|
368
|
+
info["dependencies"]["cupy"] = "not installed"
|
|
369
|
+
|
|
370
|
+
# Check pillow
|
|
371
|
+
try:
|
|
372
|
+
from PIL import __version__ as pil_version
|
|
373
|
+
info["dependencies"]["pillow"] = pil_version
|
|
374
|
+
except ImportError:
|
|
375
|
+
info["dependencies"]["pillow"] = "not installed"
|
|
376
|
+
|
|
377
|
+
# Check opencv
|
|
378
|
+
try:
|
|
379
|
+
import cv2
|
|
380
|
+
info["dependencies"]["opencv"] = cv2.__version__
|
|
381
|
+
except ImportError:
|
|
382
|
+
info["dependencies"]["opencv"] = "not installed"
|
|
383
|
+
|
|
384
|
+
# Check comtypes
|
|
385
|
+
try:
|
|
386
|
+
import comtypes
|
|
387
|
+
info["dependencies"]["comtypes"] = comtypes.__version__
|
|
388
|
+
except (ImportError, AttributeError):
|
|
389
|
+
info["dependencies"]["comtypes"] = "version unknown"
|
|
390
|
+
|
|
391
|
+
return info
|
|
392
|
+
|
|
393
|
+
# Version information
|
|
394
|
+
__version__ = "1.0.0"
|
|
395
|
+
__author__ = "Rapidshot Contributors"
|
|
396
|
+
__description__ = "High-performance screencapture library for Windows using Desktop Duplication API"
|
|
397
|
+
|
|
398
|
+
# Expose key classes
|
|
399
|
+
from rapidshot.core import ScreenCapture
|
|
400
|
+
|
|
401
|
+
# Initialize factory on first import - lazy initialization
|
|
402
|
+
try:
|
|
403
|
+
get_factory()
|
|
404
|
+
except Exception as e:
|
|
405
|
+
logger.error(f"Failed to initialize RapidshotFactory on import: {e}")
|
|
406
|
+
# Let the user handle the initialization error when they try to use the library
|
|
File without changes
|
rapidshot/_libs/d3d11.py
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import ctypes
|
|
2
|
+
import ctypes.wintypes as wintypes
|
|
3
|
+
import comtypes
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
D3D11_CPU_ACCESS_WRITE = 0x10000
|
|
7
|
+
D3D11_CPU_ACCESS_READ = 0x20000
|
|
8
|
+
|
|
9
|
+
D3D_FEATURE_LEVEL_9_1 = 0x9100
|
|
10
|
+
D3D_FEATURE_LEVEL_9_2 = 0x9200
|
|
11
|
+
D3D_FEATURE_LEVEL_9_3 = 0x9300
|
|
12
|
+
D3D_FEATURE_LEVEL_10_0 = 0xA000
|
|
13
|
+
D3D_FEATURE_LEVEL_10_1 = 0xA100
|
|
14
|
+
D3D_FEATURE_LEVEL_11_0 = 0xB000
|
|
15
|
+
D3D_FEATURE_LEVEL_11_1 = 0xB100
|
|
16
|
+
|
|
17
|
+
D3D11_USAGE_DEFAULT = 0
|
|
18
|
+
D3D11_USAGE_IMMUTABLE = 1
|
|
19
|
+
D3D11_USAGE_DYNAMIC = 2
|
|
20
|
+
D3D11_USAGE_STAGING = 3
|
|
21
|
+
|
|
22
|
+
DXGI_FORMAT_B8G8R8A8_UNORM = 87
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class DXGI_SAMPLE_DESC(ctypes.Structure):
|
|
26
|
+
_fields_ = [
|
|
27
|
+
("Count", wintypes.UINT),
|
|
28
|
+
("Quality", wintypes.UINT),
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class D3D11_BOX(ctypes.Structure):
|
|
33
|
+
_fields_ = [
|
|
34
|
+
("left", wintypes.UINT),
|
|
35
|
+
("top", wintypes.UINT),
|
|
36
|
+
("front", wintypes.UINT),
|
|
37
|
+
("right", wintypes.UINT),
|
|
38
|
+
("bottom", wintypes.UINT),
|
|
39
|
+
("back", wintypes.UINT),
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class D3D11_TEXTURE2D_DESC(ctypes.Structure):
|
|
44
|
+
_fields_ = [
|
|
45
|
+
("Width", wintypes.UINT),
|
|
46
|
+
("Height", wintypes.UINT),
|
|
47
|
+
("MipLevels", wintypes.UINT),
|
|
48
|
+
("ArraySize", wintypes.UINT),
|
|
49
|
+
("Format", wintypes.UINT),
|
|
50
|
+
("SampleDesc", DXGI_SAMPLE_DESC),
|
|
51
|
+
("Usage", wintypes.UINT),
|
|
52
|
+
("BindFlags", wintypes.UINT),
|
|
53
|
+
("CPUAccessFlags", wintypes.UINT),
|
|
54
|
+
("MiscFlags", wintypes.UINT),
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class ID3D11DeviceChild(comtypes.IUnknown):
|
|
59
|
+
_iid_ = comtypes.GUID("{1841e5c8-16b0-489b-bcc8-44cfb0d5deae}")
|
|
60
|
+
_methods_ = [
|
|
61
|
+
comtypes.STDMETHOD(None, "GetDevice"),
|
|
62
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "GetPrivateData"),
|
|
63
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "SetPrivateData"),
|
|
64
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "SetPrivateDataInterface"),
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class ID3D11Resource(ID3D11DeviceChild):
|
|
69
|
+
_iid_ = comtypes.GUID("{dc8e63f3-d12b-4952-b47b-5e45026a862d}")
|
|
70
|
+
_methods_ = [
|
|
71
|
+
comtypes.STDMETHOD(None, "GetType"),
|
|
72
|
+
comtypes.STDMETHOD(None, "SetEvictionPriority"),
|
|
73
|
+
comtypes.STDMETHOD(wintypes.UINT, "GetEvictionPriority"),
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class ID3D11Texture2D(ID3D11Resource):
|
|
78
|
+
_iid_ = comtypes.GUID("{6f15aaf2-d208-4e89-9ab4-489535d34f9c}")
|
|
79
|
+
_methods_ = [
|
|
80
|
+
comtypes.STDMETHOD(None, "GetDesc", [ctypes.POINTER(D3D11_TEXTURE2D_DESC)]),
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class ID3D11DeviceContext(ID3D11DeviceChild):
|
|
85
|
+
_iid_ = comtypes.GUID("{c0bfa96c-e089-44fb-8eaf-26f8796190da}")
|
|
86
|
+
_methods_ = [
|
|
87
|
+
comtypes.STDMETHOD(None, "VSSetConstantBuffers"),
|
|
88
|
+
comtypes.STDMETHOD(None, "PSSetShaderResources"),
|
|
89
|
+
comtypes.STDMETHOD(None, "PSSetShader"),
|
|
90
|
+
comtypes.STDMETHOD(None, "PSSetSamplers"),
|
|
91
|
+
comtypes.STDMETHOD(None, "VSSetShader"),
|
|
92
|
+
comtypes.STDMETHOD(None, "DrawIndexed"),
|
|
93
|
+
comtypes.STDMETHOD(None, "Draw"),
|
|
94
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "Map"),
|
|
95
|
+
comtypes.STDMETHOD(None, "Unmap"),
|
|
96
|
+
comtypes.STDMETHOD(None, "PSSetConstantBuffers"),
|
|
97
|
+
comtypes.STDMETHOD(None, "IASetInputLayout"),
|
|
98
|
+
comtypes.STDMETHOD(None, "IASetVertexBuffers"),
|
|
99
|
+
comtypes.STDMETHOD(None, "IASetIndexBuffer"),
|
|
100
|
+
comtypes.STDMETHOD(None, "DrawIndexedInstanced"),
|
|
101
|
+
comtypes.STDMETHOD(None, "DrawInstanced"),
|
|
102
|
+
comtypes.STDMETHOD(None, "GSSetConstantBuffers"),
|
|
103
|
+
comtypes.STDMETHOD(None, "GSSetShader"),
|
|
104
|
+
comtypes.STDMETHOD(None, "IASetPrimitiveTopology"),
|
|
105
|
+
comtypes.STDMETHOD(None, "VSSetShaderResources"),
|
|
106
|
+
comtypes.STDMETHOD(None, "VSSetSamplers"),
|
|
107
|
+
comtypes.STDMETHOD(None, "Begin"),
|
|
108
|
+
comtypes.STDMETHOD(None, "End"),
|
|
109
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "GetData"),
|
|
110
|
+
comtypes.STDMETHOD(None, "SetPredication"),
|
|
111
|
+
comtypes.STDMETHOD(None, "GSSetShaderResources"),
|
|
112
|
+
comtypes.STDMETHOD(None, "GSSetSamplers"),
|
|
113
|
+
comtypes.STDMETHOD(None, "OMSetRenderTargets"),
|
|
114
|
+
comtypes.STDMETHOD(None, "OMSetRenderTargetsAndUnorderedAccessViews"),
|
|
115
|
+
comtypes.STDMETHOD(None, "OMSetBlendState"),
|
|
116
|
+
comtypes.STDMETHOD(None, "OMSetDepthStencilState"),
|
|
117
|
+
comtypes.STDMETHOD(None, "SOSetTargets"),
|
|
118
|
+
comtypes.STDMETHOD(None, "DrawAuto"),
|
|
119
|
+
comtypes.STDMETHOD(None, "DrawIndexedInstancedIndirect"),
|
|
120
|
+
comtypes.STDMETHOD(None, "DrawInstancedIndirect"),
|
|
121
|
+
comtypes.STDMETHOD(None, "Dispatch"),
|
|
122
|
+
comtypes.STDMETHOD(None, "DispatchIndirect"),
|
|
123
|
+
comtypes.STDMETHOD(None, "RSSetState"),
|
|
124
|
+
comtypes.STDMETHOD(None, "RSSetViewports"),
|
|
125
|
+
comtypes.STDMETHOD(None, "RSSetScissorRects"),
|
|
126
|
+
comtypes.STDMETHOD(
|
|
127
|
+
None,
|
|
128
|
+
"CopySubresourceRegion",
|
|
129
|
+
[
|
|
130
|
+
ctypes.POINTER(ID3D11Resource),
|
|
131
|
+
wintypes.UINT,
|
|
132
|
+
wintypes.UINT,
|
|
133
|
+
wintypes.UINT,
|
|
134
|
+
wintypes.UINT,
|
|
135
|
+
ctypes.POINTER(ID3D11Resource),
|
|
136
|
+
wintypes.UINT,
|
|
137
|
+
ctypes.POINTER(D3D11_BOX),
|
|
138
|
+
],
|
|
139
|
+
),
|
|
140
|
+
comtypes.STDMETHOD(
|
|
141
|
+
None,
|
|
142
|
+
"CopyResource",
|
|
143
|
+
[ctypes.POINTER(ID3D11Resource), ctypes.POINTER(ID3D11Resource)],
|
|
144
|
+
),
|
|
145
|
+
comtypes.STDMETHOD(None, "UpdateSubresource"),
|
|
146
|
+
comtypes.STDMETHOD(None, "CopyStructureCount"),
|
|
147
|
+
comtypes.STDMETHOD(None, "ClearRenderTargetView"),
|
|
148
|
+
comtypes.STDMETHOD(None, "ClearUnorderedAccessViewUint"),
|
|
149
|
+
comtypes.STDMETHOD(None, "ClearUnorderedAccessViewFloat"),
|
|
150
|
+
comtypes.STDMETHOD(None, "ClearDepthStencilView"),
|
|
151
|
+
comtypes.STDMETHOD(None, "GenerateMips"),
|
|
152
|
+
comtypes.STDMETHOD(None, "SetResourceMinLOD"),
|
|
153
|
+
comtypes.STDMETHOD(wintypes.FLOAT, "GetResourceMinLOD"),
|
|
154
|
+
comtypes.STDMETHOD(None, "ResolveSubresource"),
|
|
155
|
+
comtypes.STDMETHOD(None, "ExecuteCommandList"),
|
|
156
|
+
comtypes.STDMETHOD(None, "HSSetShaderResources"),
|
|
157
|
+
comtypes.STDMETHOD(None, "HSSetShader"),
|
|
158
|
+
comtypes.STDMETHOD(None, "HSSetSamplers"),
|
|
159
|
+
comtypes.STDMETHOD(None, "HSSetConstantBuffers"),
|
|
160
|
+
comtypes.STDMETHOD(None, "DSSetShaderResources"),
|
|
161
|
+
comtypes.STDMETHOD(None, "DSSetShader"),
|
|
162
|
+
comtypes.STDMETHOD(None, "DSSetSamplers"),
|
|
163
|
+
comtypes.STDMETHOD(None, "DSSetConstantBuffers"),
|
|
164
|
+
comtypes.STDMETHOD(None, "CSSetShaderResources"),
|
|
165
|
+
comtypes.STDMETHOD(None, "CSSetUnorderedAccessViews"),
|
|
166
|
+
comtypes.STDMETHOD(None, "CSSetShader"),
|
|
167
|
+
comtypes.STDMETHOD(None, "CSSetSamplers"),
|
|
168
|
+
comtypes.STDMETHOD(None, "CSSetConstantBuffers"),
|
|
169
|
+
comtypes.STDMETHOD(None, "VSGetConstantBuffers"),
|
|
170
|
+
comtypes.STDMETHOD(None, "PSGetShaderResources"),
|
|
171
|
+
comtypes.STDMETHOD(None, "PSGetShader"),
|
|
172
|
+
comtypes.STDMETHOD(None, "PSGetSamplers"),
|
|
173
|
+
comtypes.STDMETHOD(None, "VSGetShader"),
|
|
174
|
+
comtypes.STDMETHOD(None, "PSGetConstantBuffers"),
|
|
175
|
+
comtypes.STDMETHOD(None, "IAGetInputLayout"),
|
|
176
|
+
comtypes.STDMETHOD(None, "IAGetVertexBuffers"),
|
|
177
|
+
comtypes.STDMETHOD(None, "IAGetIndexBuffer"),
|
|
178
|
+
comtypes.STDMETHOD(None, "GSGetConstantBuffers"),
|
|
179
|
+
comtypes.STDMETHOD(None, "GSGetShader"),
|
|
180
|
+
comtypes.STDMETHOD(None, "IAGetPrimitiveTopology"),
|
|
181
|
+
comtypes.STDMETHOD(None, "VSGetShaderResources"),
|
|
182
|
+
comtypes.STDMETHOD(None, "VSGetSamplers"),
|
|
183
|
+
comtypes.STDMETHOD(None, "GetPredication"),
|
|
184
|
+
comtypes.STDMETHOD(None, "GSGetShaderResources"),
|
|
185
|
+
comtypes.STDMETHOD(None, "GSGetSamplers"),
|
|
186
|
+
comtypes.STDMETHOD(None, "OMGetRenderTargets"),
|
|
187
|
+
comtypes.STDMETHOD(None, "OMGetRenderTargetsAndUnorderedAccessViews"),
|
|
188
|
+
comtypes.STDMETHOD(None, "OMGetBlendState"),
|
|
189
|
+
comtypes.STDMETHOD(None, "OMGetDepthStencilState"),
|
|
190
|
+
comtypes.STDMETHOD(None, "SOGetTargets"),
|
|
191
|
+
comtypes.STDMETHOD(None, "RSGetState"),
|
|
192
|
+
comtypes.STDMETHOD(None, "RSGetViewports"),
|
|
193
|
+
comtypes.STDMETHOD(None, "RSGetScissorRects"),
|
|
194
|
+
comtypes.STDMETHOD(None, "HSGetShaderResources"),
|
|
195
|
+
comtypes.STDMETHOD(None, "HSGetShader"),
|
|
196
|
+
comtypes.STDMETHOD(None, "HSGetSamplers"),
|
|
197
|
+
comtypes.STDMETHOD(None, "HSGetConstantBuffers"),
|
|
198
|
+
comtypes.STDMETHOD(None, "DSGetShaderResources"),
|
|
199
|
+
comtypes.STDMETHOD(None, "DSGetShader"),
|
|
200
|
+
comtypes.STDMETHOD(None, "DSGetSamplers"),
|
|
201
|
+
comtypes.STDMETHOD(None, "DSGetConstantBuffers"),
|
|
202
|
+
comtypes.STDMETHOD(None, "CSGetShaderResources"),
|
|
203
|
+
comtypes.STDMETHOD(None, "CSGetUnorderedAccessViews"),
|
|
204
|
+
comtypes.STDMETHOD(None, "CSGetShader"),
|
|
205
|
+
comtypes.STDMETHOD(None, "CSGetSamplers"),
|
|
206
|
+
comtypes.STDMETHOD(None, "CSGetConstantBuffers"),
|
|
207
|
+
comtypes.STDMETHOD(None, "ClearState"),
|
|
208
|
+
comtypes.STDMETHOD(None, "Flush"),
|
|
209
|
+
comtypes.STDMETHOD(None, "GetType"),
|
|
210
|
+
comtypes.STDMETHOD(wintypes.UINT, "GetContextFlags"),
|
|
211
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "FinishCommandList"),
|
|
212
|
+
]
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
class ID3D11Device(comtypes.IUnknown):
|
|
216
|
+
_iid_ = comtypes.GUID("{db6f6ddb-ac77-4e88-8253-819df9bbf140}")
|
|
217
|
+
_methods_ = [
|
|
218
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateBuffer"),
|
|
219
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateTexture1D"),
|
|
220
|
+
comtypes.STDMETHOD(
|
|
221
|
+
comtypes.HRESULT,
|
|
222
|
+
"CreateTexture2D",
|
|
223
|
+
[
|
|
224
|
+
ctypes.POINTER(D3D11_TEXTURE2D_DESC),
|
|
225
|
+
ctypes.POINTER(None),
|
|
226
|
+
ctypes.POINTER(ctypes.POINTER(ID3D11Texture2D)),
|
|
227
|
+
],
|
|
228
|
+
),
|
|
229
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateTexture3D"),
|
|
230
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateShaderResourceView"),
|
|
231
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateUnorderedAccessView"),
|
|
232
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateRenderTargetView"),
|
|
233
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateDepthStencilView"),
|
|
234
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateInputLayout"),
|
|
235
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateVertexShader"),
|
|
236
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateGeometryShader"),
|
|
237
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateGeometryShaderWithStreamOutput"),
|
|
238
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreatePixelShader"),
|
|
239
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateHullShader"),
|
|
240
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateDomainShader"),
|
|
241
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateComputeShader"),
|
|
242
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateClassLinkage"),
|
|
243
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateBlendState"),
|
|
244
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateDepthStencilState"),
|
|
245
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateRasterizerState"),
|
|
246
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateSamplerState"),
|
|
247
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateQuery"),
|
|
248
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreatePredicate"),
|
|
249
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateCounter"),
|
|
250
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CreateDeferredContext"),
|
|
251
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "OpenSharedResource"),
|
|
252
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CheckFormatSupport"),
|
|
253
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CheckMultisampleQualityLevels"),
|
|
254
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CheckCounterInfo"),
|
|
255
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CheckCounter"),
|
|
256
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "CheckFeatureSupport"),
|
|
257
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "GetPrivateData"),
|
|
258
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "SetPrivateData"),
|
|
259
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "SetPrivateDataInterface"),
|
|
260
|
+
comtypes.STDMETHOD(ctypes.c_int32, "GetFeatureLevel"),
|
|
261
|
+
comtypes.STDMETHOD(ctypes.c_uint, "GetCreationFlags"),
|
|
262
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "GetDeviceRemovedReason"),
|
|
263
|
+
comtypes.STDMETHOD(
|
|
264
|
+
None,
|
|
265
|
+
"GetImmediateContext",
|
|
266
|
+
[ctypes.POINTER(ctypes.POINTER(ID3D11DeviceContext))],
|
|
267
|
+
),
|
|
268
|
+
comtypes.STDMETHOD(comtypes.HRESULT, "SetExceptionMode"),
|
|
269
|
+
comtypes.STDMETHOD(ctypes.c_uint, "GetExceptionMode"),
|
|
270
|
+
]
|