From 54a10201011181e2f4a14af7f7e1426b1cf972b7 Mon Sep 17 00:00:00 2001 From: ASDAlexander77 Date: Tue, 13 Oct 2026 21:52:14 +0100 Subject: [PATCH] The workarounds for tslang issues fixed in pre-alpha101 are gone core/nvrhi_classes.* regenerated with pre-alpha101's tsbindgen, which keeps C++ overloads under their C++ name (createGraphicsPipeline, createMeshletPipeline, copyTexture; tslang picks one by the arguments). The counts in graphicsPipelineDesc() and graphicsState() are `x ? 1 : 0` again (TSLANG_ISSUES.md #14), stdString() multiplies by 256 (#15), nvrhi_direct's texture desc is `textureDesc` beside nvrhi.textureDesc (#18) and stdVectorSize's T is inferred (#13). An IFramebuffer argument fits neither createGraphicsPipeline overload (one takes `IFramebuffer | null`): createGraphicsPipeline() passes it through an `IFramebuffer | null` local (TSLANG_ISSUES.md #19). Co-Authored-By: Claude Opus 5.5 --- core/nvrhi.ts | 26 +++++++------------------- core/nvrhi_abi.linux.ts | 8 +++----- core/nvrhi_abi.win32.ts | 5 +---- core/nvrhi_classes.linux.ts | 8 ++++---- core/nvrhi_classes.win32.ts | 8 ++++---- examples/nvrhi_direct.ts | 13 ++++++------- 6 files changed, 25 insertions(+), 43 deletions(-) diff --git a/core/nvrhi.ts b/core/nvrhi.ts index 06036b8..fc8e118 100644 --- a/core/nvrhi.ts +++ b/core/nvrhi.ts @@ -232,20 +232,17 @@ export namespace nvrhi { // render state. Its RefCountPtrs hold no reference, as in computePipelineDesc. export function graphicsPipelineDesc(inputLayout: IInputLayout | null, vertexShader: IShader, pixelShader: IShader, bindingLayout: IBindingLayout | null, state: RenderState): GraphicsPipelineDesc { - // (`bindingLayout ? 1 : 0` as the count fails to compile: TSLANG_ISSUES.md #14) - let layouts: index = 0; - if (bindingLayout) { - layouts = 1; - } - return [3, 0, [inputLayout], [vertexShader], [null], [null], [null], [pixelShader], state, [false, 0, 0, 0], - [[[bindingLayout], [null], [null], [null], [null], [null], [null], [null]], layouts], 0]; + [[[bindingLayout], [null], [null], [null], [null], [null], [null], [null]], bindingLayout ? 1 : 0], 0]; } // IDevice::createGraphicsPipeline for the framebuffer's formats; null on failure. Release() it. export function createGraphicsPipeline(device: IDevice, desc: GraphicsPipelineDesc, framebuffer: IFramebuffer): IGraphicsPipeline | null { let descValue = desc; - const handle = device.createGraphicsPipeline_2(Ref(descValue), framebuffer); + // (passed as the overload's `IFramebuffer | null`: an IFramebuffer fits no overload, + // TSLANG_ISSUES.md #19) + const framebufferArg: IFramebuffer | null = framebuffer; + const handle = device.createGraphicsPipeline(Ref(descValue), framebufferArg); return handle.ptr_ ? handle.ptr_ : null; } @@ -261,15 +258,6 @@ export namespace nvrhi { const scissor: Rect = [Math.floor(viewport.minX), Math.ceil(viewport.maxX), Math.floor(viewport.minY), Math.ceil(viewport.maxY)]; const noBuffer: VertexBufferBinding = [null, 0, 0]; - // (counts from `x ? 1 : 0` fail to compile: TSLANG_ISSUES.md #14) - let bindingSets: index = 0; - if (bindingSet) { - bindingSets = 1; - } - let vertexBuffers: index = 0; - if (vertexBuffer) { - vertexBuffers = 1; - } const vertexBinding: VertexBufferBinding = [vertexBuffer, 0, 0]; return [pipeline, framebuffer, @@ -278,9 +266,9 @@ export namespace nvrhi { [[scissor, noRect, noRect, noRect, noRect, noRect, noRect, noRect, noRect, noRect, noRect, noRect, noRect, noRect, noRect, noRect], 1]], [false, 0, 0, 0], [0, 0, 0, 0], 0, 0, 1, - [[bindingSet, null, null, null, null, null, null, null], bindingSets], + [[bindingSet, null, null, null, null, null, null, null], bindingSet ? 1 : 0], [[vertexBinding, noBuffer, noBuffer, noBuffer, noBuffer, noBuffer, noBuffer, noBuffer, - noBuffer, noBuffer, noBuffer, noBuffer, noBuffer, noBuffer, noBuffer, noBuffer], vertexBuffers], + noBuffer, noBuffer, noBuffer, noBuffer, noBuffer, noBuffer, noBuffer, noBuffer], vertexBuffer ? 1 : 0], [indexBuffer, indexFormat, 0], null, null]; } diff --git a/core/nvrhi_abi.linux.ts b/core/nvrhi_abi.linux.ts index e033470..564c64e 100644 --- a/core/nvrhi_abi.linux.ts +++ b/core/nvrhi_abi.linux.ts @@ -26,13 +26,11 @@ export namespace nvrhi { } } - // byte 0 is the size times two, byte k + 1 character k. (`shift *= 256` would multiply in - // 32 bits, losing the characters from the fourth on: TSLANG_ISSUES.md #15) - const BYTE: u64 = 256; + // byte 0 is the size times two, byte k + 1 character k let word0: u64 = size * 2; let word1: u64 = 0; let word2: u64 = 0; - let shift: u64 = BYTE; + let shift: u64 = 256; for (let i = 0; i < size; i++) { const byte = i + 1; if (byte == 8 || byte == 16) { @@ -46,7 +44,7 @@ export namespace nvrhi { } else { word2 += char * shift; } - shift *= BYTE; + shift *= 256; } return [[word0, word1, word2]]; diff --git a/core/nvrhi_abi.win32.ts b/core/nvrhi_abi.win32.ts index fc4a638..cf1dd0c 100644 --- a/core/nvrhi_abi.win32.ts +++ b/core/nvrhi_abi.win32.ts @@ -27,9 +27,6 @@ export namespace nvrhi { } } - // (`shift *= 256` would multiply in 32 bits, losing the characters from the fifth on: - // TSLANG_ISSUES.md #15) - const BYTE: u64 = 256; let buffer0: u64 = 0; let buffer1: u64 = 0; let shift: u64 = 1; @@ -43,7 +40,7 @@ export namespace nvrhi { } else { buffer1 += char * shift; } - shift *= BYTE; + shift *= 256; } return [[[[buffer0, buffer1], size, 15]]]; diff --git a/core/nvrhi_classes.linux.ts b/core/nvrhi_classes.linux.ts index a15c930..d214edf 100644 --- a/core/nvrhi_classes.linux.ts +++ b/core/nvrhi_classes.linux.ts @@ -271,13 +271,13 @@ export namespace nvrhi { @cppnontrivial @slot(42) createGraphicsPipeline(desc: Ref, fbinfo: Ref): RefCountPtr; @cppnontrivial - @slot(43) createGraphicsPipeline_2(desc: Ref, fb: IFramebuffer | null): RefCountPtr; + @slot(43) createGraphicsPipeline(desc: Ref, fb: IFramebuffer | null): RefCountPtr; @cppnontrivial @slot(44) createComputePipeline(desc: Ref): RefCountPtr; @cppnontrivial @slot(45) createMeshletPipeline(desc: Ref, fbinfo: Ref): RefCountPtr; @cppnontrivial - @slot(46) createMeshletPipeline_2(desc: Ref, fb: IFramebuffer | null): RefCountPtr; + @slot(46) createMeshletPipeline(desc: Ref, fb: IFramebuffer | null): RefCountPtr; @cppnontrivial @slot(47) createRayTracingPipeline(desc: Ref): RefCountPtr; @cppnontrivial @@ -331,8 +331,8 @@ export namespace nvrhi { // skipped: clearDepthStencilTexture — parameter 'subresources': struct passed by value // skipped: clearTextureUInt — parameter 'subresources': struct passed by value @slot(13) copyTexture(dest: ITexture | null, destSlice: Ref, src: ITexture | null, srcSlice: Ref): void; - @slot(14) copyTexture_2(dest: IStagingTexture | null, destSlice: Ref, src: ITexture | null, srcSlice: Ref): void; - @slot(15) copyTexture_3(dest: ITexture | null, destSlice: Ref, src: IStagingTexture | null, srcSlice: Ref): void; + @slot(14) copyTexture(dest: IStagingTexture | null, destSlice: Ref, src: ITexture | null, srcSlice: Ref): void; + @slot(15) copyTexture(dest: ITexture | null, destSlice: Ref, src: IStagingTexture | null, srcSlice: Ref): void; @slot(16) writeTexture(dest: ITexture | null, arraySlice: u32, mipLevel: u32, data: Opaque | null, rowPitch: index, depthPitch: index): void; @slot(17) resolveTexture(dest: ITexture | null, dstSubresources: Ref, src: ITexture | null, srcSubresources: Ref): void; @slot(18) writeBuffer(b: IBuffer | null, data: Opaque | null, dataSize: index, destOffsetBytes: u64): void; diff --git a/core/nvrhi_classes.win32.ts b/core/nvrhi_classes.win32.ts index f0d6447..1e403cb 100644 --- a/core/nvrhi_classes.win32.ts +++ b/core/nvrhi_classes.win32.ts @@ -273,13 +273,13 @@ export namespace nvrhi { @cppnontrivial @slot(42) createGraphicsPipeline(desc: Ref, fbinfo: Ref): RefCountPtr; @cppnontrivial - @slot(41) createGraphicsPipeline_2(desc: Ref, fb: IFramebuffer | null): RefCountPtr; + @slot(41) createGraphicsPipeline(desc: Ref, fb: IFramebuffer | null): RefCountPtr; @cppnontrivial @slot(43) createComputePipeline(desc: Ref): RefCountPtr; @cppnontrivial @slot(45) createMeshletPipeline(desc: Ref, fbinfo: Ref): RefCountPtr; @cppnontrivial - @slot(44) createMeshletPipeline_2(desc: Ref, fb: IFramebuffer | null): RefCountPtr; + @slot(44) createMeshletPipeline(desc: Ref, fb: IFramebuffer | null): RefCountPtr; @cppnontrivial @slot(46) createRayTracingPipeline(desc: Ref): RefCountPtr; @cppnontrivial @@ -333,8 +333,8 @@ export namespace nvrhi { // skipped: clearDepthStencilTexture — parameter 'subresources': struct passed by value // skipped: clearTextureUInt — parameter 'subresources': struct passed by value @slot(14) copyTexture(dest: ITexture | null, destSlice: Ref, src: ITexture | null, srcSlice: Ref): void; - @slot(13) copyTexture_2(dest: IStagingTexture | null, destSlice: Ref, src: ITexture | null, srcSlice: Ref): void; - @slot(12) copyTexture_3(dest: ITexture | null, destSlice: Ref, src: IStagingTexture | null, srcSlice: Ref): void; + @slot(13) copyTexture(dest: IStagingTexture | null, destSlice: Ref, src: ITexture | null, srcSlice: Ref): void; + @slot(12) copyTexture(dest: ITexture | null, destSlice: Ref, src: IStagingTexture | null, srcSlice: Ref): void; @slot(15) writeTexture(dest: ITexture | null, arraySlice: u32, mipLevel: u32, data: Opaque | null, rowPitch: index, depthPitch: index): void; @slot(16) resolveTexture(dest: ITexture | null, dstSubresources: Ref, src: ITexture | null, srcSubresources: Ref): void; @slot(17) writeBuffer(b: IBuffer | null, data: Opaque | null, dataSize: index, destOffsetBytes: u64): void; diff --git a/examples/nvrhi_direct.ts b/examples/nvrhi_direct.ts index b8757dc..0726289 100644 --- a/examples/nvrhi_direct.ts +++ b/examples/nvrhi_direct.ts @@ -175,11 +175,10 @@ namespace NvrhiDirect { check(false, "IDevice::createTexture"); return; } - // (named so as not to hide nvrhi.textureDesc below: TSLANG_ISSUES.md #18) - const keptTextureDesc = Deref(texture.getDesc()); - check(keptTextureDesc.width == TEXTURE_SIZE && keptTextureDesc.height == TEXTURE_SIZE - && keptTextureDesc.format == Format.RGBA8_UNORM && keptTextureDesc.isRenderTarget - && nvrhi.stdStringIs(keptTextureDesc.debugName, "Cleared texture"), "ITexture::getDesc"); + const textureDesc = Deref(texture.getDesc()); + check(textureDesc.width == TEXTURE_SIZE && textureDesc.height == TEXTURE_SIZE + && textureDesc.format == Format.RGBA8_UNORM && textureDesc.isRenderTarget + && nvrhi.stdStringIs(textureDesc.debugName, "Cleared texture"), "ITexture::getDesc"); check(nvrhi.getNativeObject(texture, isD3D12 ? nvrhi.OBJECT_TYPE_D3D12_RESOURCE : nvrhi.OBJECT_TYPE_VK_IMAGE) != null, "the texture has its native resource"); @@ -224,9 +223,9 @@ namespace NvrhiDirect { return; } const layoutDesc = Deref(bindingLayout.getDesc()); - check(layoutDesc.visibility == nvrhi.SHADER_TYPE_COMPUTE && nvrhi.stdVectorSize(layoutDesc.bindings) == 2, + check(layoutDesc.visibility == nvrhi.SHADER_TYPE_COMPUTE && nvrhi.stdVectorSize(layoutDesc.bindings) == 2, "IBindingLayout::getDesc"); - check(nvrhi.stdVectorSize(Deref(bindingSet.getDesc()).bindings) == 2, "IBindingSet::getDesc"); + check(nvrhi.stdVectorSize(Deref(bindingSet.getDesc()).bindings) == 2, "IBindingSet::getDesc"); check(bindingSet.getLayout() == bindingLayout, "IBindingSet::getLayout"); const pipeline = nvrhi.createComputePipeline(device, nvrhi.computePipelineDesc(shader, bindingLayout)); if (!pipeline) {