.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/extras_dxc.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_extras_dxc.py: Extras DXC ---------- Simple example to show how the wgpu-native extras can be used to use dxc compiler for DX12. Since this will only work on Windows it's not meant for the test suite. You can run the download script using `python tools/download_dxc.py` to download the latest Dxc release from GitHub. And extract it to the resource directory. .. GENERATED FROM PYTHON SOURCE LINES 9-51 .. code-block:: Python # run_example = false from rendercanvas.auto import RenderCanvas, loop # before we enumerate or request a device, we need to set the instance extras # as we import from the base examples, those do the request_device call from wgpu.backends.wgpu_native.extras import set_instance_extras set_instance_extras( backends=[ "DX12" ], # using the env var `WGPU_BACKEND_TYPE` happens later during request_device, so you can only select backends that are requested for the instance dx12_compiler="Dxc", # request the Dxc compiler to be used # dxc_path can be set for a custom Dxc location dxc_max_shader_model=6.7, # by setting these limits to percentages 0..100 you will get a Validation Error, should too much memory be requested. budget_for_device_creation=99, budget_for_device_loss=97, ) try: from .cube import setup_drawing_sync except ImportError: from cube import setup_drawing_sync canvas = RenderCanvas(title="Cube example on DX12 using Dxc") draw_frame = setup_drawing_sync(canvas.get_wgpu_context()) @canvas.request_draw def animate(): draw_frame() canvas.request_draw() if __name__ == "__main__": loop.run() # But how do you know this is actually using Dxc over Fxc? # perhaps performance, but we can also use Debug tools to be sure. .. _sphx_glr_download_gallery_extras_dxc.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: extras_dxc.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: extras_dxc.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: extras_dxc.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_