Code Monkey home page Code Monkey logo

Comments (7)

vincentisambart avatar vincentisambart commented on August 31, 2024 1

Hello,

I've investigated a bit this problem and it seems the blue Tiger is due to piet-gpu copying from an RGBA8 texture (one piet-gpu created itself) to an BGRA8 one (the swapchain one the system created). It seems MTLBlitCommandEncoder won't do the conversion for you. The copyFromTexture:toTexture: doc explicitly says that source and destination must have the same format. It's not written in the copyFromTexture:sourceSlice:.. doc which is the one piet-gpu uses, but it seems to have the same restriction.

I was able to get the Tiger to have the correct color with any of the two following changes:

  • Changing the format of the working texture piet-gpu creates to be BGRA8 instead of RGBA8.
  • Replacing the texture copy by a basic compute shader that just reads from a source texture and copy that to a destination texture (note that that requires to make the MetalLayer not framebuffer only metal_layer.set_framebuffer_only(false);). I don't know Metal much so it was mostly based on some Apple sample code.

Changing the working texture format is just a 1-line change but some other part of the code might expect RGBA8, and using BGRA8 even though the generic code asks for RGBA8 would probably be confusing.

For the basic compute shader I can make a PR if you really want but I'm not sure it would be of much use.

from vello.

raphlinus avatar raphlinus commented on August 31, 2024

Can you give a little more detail about your macOS environment? I'm using an M1 as my daily driver and haven't seen this. I do have access to other hardware though.

Obviously it's hard to say what the problem is without digging, but I'd be suspicious of the shader translation in spirv-cross, which is the same as what it would be in MoltenVK. It should in theory be possible to compile the Vulkan version on mac, but it's very unlikely it will solve this problem.

Does forcing the session.gpu_info().workgroup_limits.max_invocations >= 1024 predicate in piet-gpu/src/lib.rs to false help? If so, I think I know what it is.

from vello.

KodaKoder avatar KodaKoder commented on August 31, 2024

Hello
thanks for your help
I tried something like
"if session.gpu_info().workgroup_limits.max_invocations >= 1024 && false" but did not change the result

I attach some samples on different devices
maybe is the macOS version?

IMG_4736

IMG_9321

PNG image

from vello.

raphlinus avatar raphlinus commented on August 31, 2024

Thanks for the report, I will investigate. I am able to repro the inverted colors on my M1 :). GPU portability is hard.

from vello.

KodaKoder avatar KodaKoder commented on August 31, 2024

If you need more informations or
I can help you in any way just tell me

from vello.

DJMcNab avatar DJMcNab commented on August 31, 2024

Since #193 , we've moved over to using wgpu. Can this still be reproduced?

from vello.

raphlinus avatar raphlinus commented on August 31, 2024

A lot has changed since this issue was filed and we're not seeing similar things now, so closing. Thanks for the report!

from vello.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.