Hi, OK, the problem with emscripten wgpu::Texture::GetFormat is in the wgpuTextureGetFormat function in library_webgpu.js
This is currently just directly returning webgpu texture.format, which is a string (eg: "rgba8unorm"), but dawn texture formats are ints so this needs to be converted. I verified this is the problem by hacking wgpuTextureGetFormat to handle just the formats I use: wgpuTextureGetFormat: function(textureId) { var texture = WebGPU.mgrTexture.get(textureId); // Note: This switch currently MIA! switch(texture.format) { case 'rgba8unorm':return 18; case 'rgba8unorm-srgb':return 19; } return 0; }, Bye! Mark On Wednesday, February 8, 2023 at 1:33:09 PM UTC+13 Mark Sibly wrote: > Hi, > > I'm writing an emscripten/webgpu app and Texture::GetFormat() is always > returning 0. The texture is otherwise working and usable so I can work > around it for now. > > GetFormat works as expected with the same code built natively using the > dawn lib, and GetWidth and GetHeight are also working fin on both > emscripten and native. > > Here's my texture creation code: > > wgpu::Extent3D size = {width, height, 1}; > > wgpu::TextureDescriptor desc; > desc.usage = usage; > desc.dimension = wgpu::TextureDimension::e2D; > desc.size = size; > desc.format = format; > desc.mipLevelCount = mipmap ? > (uint32_t)std::floor(log2(std::min(width, height))) + 1 : 1; > desc.sampleCount = 1; > > log() << "### Creating texture:" << (int)desc.format << > desc.size.width << desc.size.height; > > auto texture = device.CreateTexture(&desc); > > log() << "### Created texture:" << (int)texture.GetFormat() << > texture.GetWidth() << texture.GetHeight(); > > I had a quick look at the library_webgpu.js code but the 2 lines there > look fine. > > Also, emscripten wgpu::Buffer appears to be missing the GetMapState() > member, ditto > wgpuBufferGetMapState. > > Bye! > Mark > > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/67da018d-4c6f-42a4-9713-0d48f3c9d9aan%40googlegroups.com.