Search code examples
texturesmetal

Is it possible to declare and initialize a texture inside a .metal file?


I was just wondering, instead of creating a texture, initializing data to it via blit command encoder if it is private or by using MTLTexture replace if it not private, and passing it to GPU using setFragmentTexture, can I have the texture already ready to use inside the .metal file similar to:

constant const texture2d<half> my_texture = {/* Texture Data */};

Is this possible?


Solution

  • As per comment:

    It is not possible to do that. Each resource has to have a CPU MTLResource object.