From 893a87519bdedc2fa19dae9b9892fb89cf85b9bd Mon Sep 17 00:00:00 2001 From: Ivan Popelyshev Date: Wed, 6 Sep 2023 21:07:26 +0300 Subject: [PATCH] BaseVertexBaseInstance without multidraw --- .../drawArraysInstancedBaseInstanceWEBGL.ts | 21 ++++++++++++++++ ...ntsInstancedBaseVertexBaseInstanceWEBGL.ts | 24 +++++++++++++++++++ src/backend/spies/commandSpy.ts | 4 ++++ src/backend/states/information/extensions.ts | 1 + src/backend/utils/drawCommands.ts | 2 ++ 5 files changed, 52 insertions(+) create mode 100644 src/backend/commands/drawArraysInstancedBaseInstanceWEBGL.ts create mode 100644 src/backend/commands/drawElementsInstancedBaseVertexBaseInstanceWEBGL.ts diff --git a/src/backend/commands/drawArraysInstancedBaseInstanceWEBGL.ts b/src/backend/commands/drawArraysInstancedBaseInstanceWEBGL.ts new file mode 100644 index 0000000..814367b --- /dev/null +++ b/src/backend/commands/drawArraysInstancedBaseInstanceWEBGL.ts @@ -0,0 +1,21 @@ +import { BaseCommand } from "./baseCommand"; +import { WebGlConstants } from "../types/webglConstants"; + +export class DrawArraysInstancedBaseInstanceWEBGL extends BaseCommand { + public static readonly commandName = "drawArraysInstancedBaseInstanceWEBGL"; + + protected get spiedCommandName(): string { + return DrawArraysInstancedBaseInstanceWEBGL.commandName; + } + + protected stringifyArgs(args: IArguments): string[] { + const stringified = []; + stringified.push(WebGlConstants.stringifyWebGlConstant(args[0], "drawArraysInstanced")); + stringified.push(args[1]); + stringified.push(args[2]); + stringified.push(args[3]); + stringified.push(`baseInstance = ${args[4]}`); + + return stringified; + } +} diff --git a/src/backend/commands/drawElementsInstancedBaseVertexBaseInstanceWEBGL.ts b/src/backend/commands/drawElementsInstancedBaseVertexBaseInstanceWEBGL.ts new file mode 100644 index 0000000..4a6ad01 --- /dev/null +++ b/src/backend/commands/drawElementsInstancedBaseVertexBaseInstanceWEBGL.ts @@ -0,0 +1,24 @@ +import { BaseCommand } from "./baseCommand"; +import { WebGlConstants } from "../types/webglConstants"; + +export class DrawElementsInstancedBaseVertexBaseInstanceWEBGL extends BaseCommand { + public static readonly commandName = "drawElementsInstancedBaseVertexBaseInstanceWEBGL"; + + protected get spiedCommandName(): string { + return DrawElementsInstancedBaseVertexBaseInstanceWEBGL .commandName; + } + + protected stringifyArgs(args: IArguments): string[] { + const stringified = []; + stringified.push(WebGlConstants.stringifyWebGlConstant(args[0], "drawElementsInstanced")); + stringified.push(args[1]); + stringified.push(WebGlConstants.stringifyWebGlConstant(args[2], "drawElementsInstanced")); + stringified.push(args[3]); + stringified.push(args[4]); + + stringified.push(`baseVertex = ${args[5]}`); + stringified.push(`baseInstance = ${args[6]}`); + + return stringified; + } +} diff --git a/src/backend/spies/commandSpy.ts b/src/backend/spies/commandSpy.ts index 3948d45..61aa46c 100644 --- a/src/backend/spies/commandSpy.ts +++ b/src/backend/spies/commandSpy.ts @@ -29,6 +29,8 @@ import { MultiDrawArraysWEBGL } from "../commands/MultiDrawArraysWEBGL"; import { MultiDrawElementsInstancedBaseVertexBaseInstanceWEBGL } from "../commands/MultiDrawElementsInstancedBaseVertexBaseInstanceWEBGL"; import { MultiDrawElementsInstancedWEBGL } from "../commands/MultiDrawElementsInstancedWEBGL"; import { MultiDrawElementsWEBGL } from "../commands/MultiDrawElementsWEBGL"; +import { DrawArraysInstancedBaseInstanceWEBGL } from "../commands/drawArraysInstancedBaseInstanceWEBGL"; +import { DrawElementsInstancedBaseVertexBaseInstanceWEBGL } from "../commands/drawElementsInstancedBaseVertexBaseInstanceWEBGL"; import { Scissor } from "../commands/scissor"; import { StencilMask } from "../commands/stencilMask"; @@ -161,6 +163,8 @@ export class CommandSpy { [MultiDrawElementsInstancedBaseVertexBaseInstanceWEBGL.commandName]: (options: IContextInformation) => new MultiDrawElementsInstancedBaseVertexBaseInstanceWEBGL(options), [MultiDrawElementsInstancedWEBGL.commandName]: (options: IContextInformation) => new MultiDrawElementsInstancedWEBGL(options), [MultiDrawElementsWEBGL.commandName]: (options: IContextInformation) => new MultiDrawElementsWEBGL(options), + [DrawArraysInstancedBaseInstanceWEBGL.commandName]: (options: IContextInformation) => new DrawArraysInstancedBaseInstanceWEBGL(options), + [DrawElementsInstancedBaseVertexBaseInstanceWEBGL.commandName]: (options: IContextInformation) => new DrawElementsInstancedBaseVertexBaseInstanceWEBGL(options), [Scissor.commandName]: (options: IContextInformation) => new Scissor(options), [StencilMask.commandName]: (options: IContextInformation) => new StencilMask(options), [StencilMaskSeparate.commandName]: (options: IContextInformation) => new StencilMaskSeparate(options), diff --git a/src/backend/states/information/extensions.ts b/src/backend/states/information/extensions.ts index 8a0906e..d344c73 100644 --- a/src/backend/states/information/extensions.ts +++ b/src/backend/states/information/extensions.ts @@ -71,6 +71,7 @@ export class Extensions extends BaseState { // { name: "WEBGL_debug_shaders", description: "" }, { name: "WEBGL_multi_draw", description: ""}, { name: "WEBGL_multi_draw_instanced_base_vertex_base_instance", description: ""}, + { name: "WEBGL_draw_instanced_base_vertex_base_instance", description: ""}, ], ]; diff --git a/src/backend/utils/drawCommands.ts b/src/backend/utils/drawCommands.ts index ecb5c51..84080cf 100644 --- a/src/backend/utils/drawCommands.ts +++ b/src/backend/utils/drawCommands.ts @@ -12,4 +12,6 @@ export const drawCommands = [ "multiDrawElementsInstancedWEBGL", "multiDrawArraysInstancedBaseInstanceWEBGL", "multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL", + "drawArraysInstancedBaseInstanceWEBGL", + "drawElementsInstancedBaseVertexBaseInstanceWEBGL" ];