|
30 | 30 | "GPUBuffer", |
31 | 31 | "GPUTexture", |
32 | 32 | "GPUTextureView", |
| 33 | + "GPUExternalTexture", |
33 | 34 | "GPUSampler", |
34 | 35 | "GPUBindGroupLayout", |
35 | 36 | "GPUBindGroup", |
36 | 37 | "GPUPipelineLayout", |
| 38 | + "GPUShaderModule", |
37 | 39 | "GPUCompilationMessage", |
38 | 40 | "GPUCompilationInfo", |
39 | | - "GPUShaderModule", |
40 | 41 | "GPUPipelineBase", |
41 | 42 | "GPUComputePipeline", |
42 | 43 | "GPURenderPipeline", |
@@ -125,17 +126,21 @@ def configure_swap_chain( |
125 | 126 | device: "GPUDevice", |
126 | 127 | format: "enums.TextureFormat", |
127 | 128 | usage: "flags.TextureUsage" = 0x10, |
| 129 | + compositing_alpha_mode: "enums.CanvasCompositingAlphaMode" = "opaque", |
128 | 130 | ): |
129 | 131 | """Get a :class:`GPUSwapChain` object for this canvas. |
130 | 132 |
|
131 | 133 | Arguments: |
132 | 134 | device (WgpuDevice): The GPU device object. |
133 | 135 | format (TextureFormat): The texture format, e.g. "bgra8unorm-srgb". |
134 | 136 | usage (TextureUsage): Default ``TextureUsage.OUTPUT_ATTACHMENT``. |
| 137 | + compositing_alpha_mode (CanvasCompositingAlphaMode): Default opaque. |
135 | 138 | """ |
136 | 139 | usage = usage or flags.TextureUsage.RENDER_ATTACHMENT |
137 | 140 | GPUSwapChain = sys.modules[device.__module__].GPUSwapChain # noqa: N806 |
138 | | - return GPUSwapChain(label, None, device, self, format, usage) |
| 141 | + return GPUSwapChain( |
| 142 | + label, None, device, self, format, usage, compositing_alpha_mode |
| 143 | + ) |
139 | 144 |
|
140 | 145 | # IDL: GPUTextureFormat getSwapChainPreferredFormat(GPUAdapter adapter); |
141 | 146 | def get_swap_chain_preferred_format(self, adapter): |
@@ -543,7 +548,7 @@ def create_shader_module(self, *, label="", code: str, source_map: dict = None): |
543 | 548 | Arguments: |
544 | 549 | label (str): A human readable label. Optional. |
545 | 550 | code (str | bytes): The shader code, as WGSL text or binary SpirV |
546 | | - (or an object implementing ``to_spirv()`` or ``to_bytes()``). |
| 551 | + (or an object implementing ``to_spirv()`` or ``to_bytes()``). |
547 | 552 | """ |
548 | 553 | raise NotImplementedError() |
549 | 554 |
|
@@ -781,6 +786,17 @@ def push_error_scope(self, filter): |
781 | 786 | def pop_error_scope(self): |
782 | 787 | raise NotImplementedError() |
783 | 788 |
|
| 789 | + # IDL: GPUExternalTexture importExternalTexture(GPUExternalTextureDescriptor descriptor); |
| 790 | + @apidiff.hide("Specific to browsers.") |
| 791 | + def import_external_texture( |
| 792 | + self, |
| 793 | + *, |
| 794 | + label="", |
| 795 | + source: object, |
| 796 | + color_space: "enums.PredefinedColorSpace" = "srgb", |
| 797 | + ): |
| 798 | + raise NotImplementedError() |
| 799 | + |
784 | 800 |
|
785 | 801 | class GPUBuffer(GPUObjectBase): |
786 | 802 | """ |
@@ -1494,8 +1510,8 @@ def set_scissor_rect(self, x, y, width, height): |
1494 | 1510 | """ |
1495 | 1511 | raise NotImplementedError() |
1496 | 1512 |
|
1497 | | - # IDL: undefined setBlendColor(GPUColor color); |
1498 | | - def set_blend_color(self, color): |
| 1513 | + # IDL: undefined setBlendConstant(GPUColor color); |
| 1514 | + def set_blend_constant(self, color): |
1499 | 1515 | """Set the blend color for the render pass. |
1500 | 1516 |
|
1501 | 1517 | Arguments: |
@@ -1592,13 +1608,6 @@ def submit(self, command_buffers): |
1592 | 1608 | """ |
1593 | 1609 | raise NotImplementedError() |
1594 | 1610 |
|
1595 | | - # IDL: undefined copyImageBitmapToTexture( GPUImageCopyImageBitmap source, GPUImageCopyTexture destination, GPUExtent3D copySize); |
1596 | | - def copy_image_bitmap_to_texture(self, source, destination, copy_size): |
1597 | | - """ |
1598 | | - TODO: not yet available in wgpu-native |
1599 | | - """ |
1600 | | - raise NotImplementedError() |
1601 | | - |
1602 | 1611 | # IDL: undefined writeBuffer( GPUBuffer buffer, GPUSize64 bufferOffset, [AllowShared] BufferSource data, optional GPUSize64 dataOffset = 0, optional GPUSize64 size); |
1603 | 1612 | def write_buffer(self, buffer, buffer_offset, data, data_offset=0, size=None): |
1604 | 1613 | """Takes the data contents and schedules a write operation of |
@@ -1683,6 +1692,11 @@ def on_submitted_work_done(self): |
1683 | 1692 | """TODO""" |
1684 | 1693 | raise NotImplementedError() |
1685 | 1694 |
|
| 1695 | + # IDL: undefined copyExternalImageToTexture( GPUImageCopyExternalImage source, GPUImageCopyTexture destination, GPUExtent3D copySize); |
| 1696 | + @apidiff.hide("Specific to browsers.") |
| 1697 | + def copy_external_image_to_texture(self, source, destination, copy_size): |
| 1698 | + raise NotImplementedError() |
| 1699 | + |
1686 | 1700 |
|
1687 | 1701 | @apidiff.change( |
1688 | 1702 | "the swapchain should be used as a context manager to obtain the texture view" |
@@ -1714,11 +1728,14 @@ class GPUSwapChain(GPUObjectBase): |
1714 | 1728 | You can obtain a swap chain using :func:`device.configure_swap_chain() <GPUDevice.configure_swap_chain>`. |
1715 | 1729 | """ |
1716 | 1730 |
|
1717 | | - def __init__(self, label, internal, device, canvas, format, usage): |
| 1731 | + def __init__( |
| 1732 | + self, label, internal, device, canvas, format, usage, compositing_alpha_mode |
| 1733 | + ): |
1718 | 1734 | super().__init__(label, internal, device) |
1719 | 1735 | self._canvas = canvas |
1720 | 1736 | self._format = format |
1721 | 1737 | self._usage = usage |
| 1738 | + self._compositing_alpha_mode = compositing_alpha_mode |
1722 | 1739 |
|
1723 | 1740 | # IDL: GPUTexture getCurrentTexture(); |
1724 | 1741 | def get_current_texture(self): |
@@ -1813,6 +1830,18 @@ def line_pos(self): |
1813 | 1830 | """The position on the line in the shader source.""" |
1814 | 1831 | raise NotImplementedError() |
1815 | 1832 |
|
| 1833 | + # IDL: readonly attribute unsigned long long offset; |
| 1834 | + @property |
| 1835 | + def offset(self): |
| 1836 | + """Offset of ...""" |
| 1837 | + raise NotImplementedError() |
| 1838 | + |
| 1839 | + # IDL: readonly attribute unsigned long long length; |
| 1840 | + @property |
| 1841 | + def length(self): |
| 1842 | + """The length of the line?""" |
| 1843 | + raise NotImplementedError() |
| 1844 | + |
1816 | 1845 |
|
1817 | 1846 | # FIXME: new class to implement |
1818 | 1847 | class GPUCompilationInfo: |
@@ -1850,6 +1879,10 @@ def __init__(self, type, gpu_uncaptured_error_event_init_dict): |
1850 | 1879 | pass |
1851 | 1880 |
|
1852 | 1881 |
|
| 1882 | +class GPUExternalTexture(GPUObjectBase): |
| 1883 | + """Ignore this - specific to browsers.""" |
| 1884 | + |
| 1885 | + |
1853 | 1886 | # %%%%% Post processing |
1854 | 1887 |
|
1855 | 1888 | apidiff.remove_hidden_methods(globals()) |
0 commit comments