Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 28, 2025

This PR implements the WebGL validateProgram method as requested in the issue, following the MDN specification with complete end-to-end implementation and comprehensive test coverage.

Overview

The validateProgram method validates a WebGL program against the current WebGL state and stores the validation result in the program's VALIDATE_STATUS parameter, which can be queried using getProgramParameter.

Usage

// Create and link a program
const program = gl.createProgram();
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);

// Validate the program
gl.validateProgram(program);

// Check validation status
const isValid = gl.getProgramParameter(program, gl.VALIDATE_STATUS);
if (isValid) {
    gl.useProgram(program);
} else {
    console.error('Program validation failed:', gl.getProgramInfoLog(program));
}

Implementation Details

Command Buffer Layer:

  • Added COMMAND_BUFFER_VALIDATE_PROGRAM_REQ enum constant
  • Added ValidateProgramCommandBufferRequest class following existing patterns

Client Graphics Layer:

  • Implemented WebGLContext::validateProgram() method with proper error handling
  • Added validation status tracking to WebGLProgram class (validateStatus_, setValidateStatus(), getValidateStatus())
  • Updated getProgramParameter() to handle WEBGL_VALIDATE_STATUS queries

JavaScript Bindings:

  • Added ValidateProgram method to WebGLBaseRenderingContext with proper argument validation
  • Registered the method in N-API binding macros

Renderer Processing:

  • Added OnValidateProgram function that calls glValidateProgram() on the OpenGL program
  • Registered the VALIDATE_PROGRAM command buffer handler to route requests to the renderer
  • Follows the same pattern as other simple program operations like useProgram

Test Coverage

Added comprehensive test page at fixtures/html/webgl-conformance/validateprogram-test.html that covers:

  • API Availability: Verifies method and constant existence
  • Valid Program Tests: Tests validation of properly linked programs
  • Invalid Program Tests: Tests validation of programs with shader incompatibilities
  • Error Handling: Tests null/invalid program scenarios
  • Integration Tests: Tests validateProgram with useProgram workflow
  • Visual Results: Color-coded pass/fail indicators with detailed test descriptions

WebGL Specification Compliance

✅ Method signature: void validateProgram(WebGLProgram program)
✅ Validates program against current WebGL state
✅ Stores result in VALIDATE_STATUS parameter (0x8B83)
✅ Queryable via getProgramParameter(program, gl.VALIDATE_STATUS)
✅ Proper error handling for null/invalid programs
✅ Complete end-to-end processing from JavaScript to OpenGL renderer

The implementation provides a complete data flow from the JavaScript API through the command buffer system to the OpenGL renderer, ensuring the validation is properly executed and results are accessible to applications.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] 参考 https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/validateProgram 在 src/client/graphics, src/bindings/webgl 以及相关模块支持 validateProgram Implement WebGL validateProgram method following MDN specification Aug 28, 2025
Copilot AI requested a review from yorkie August 28, 2025 07:09
Copy link
Collaborator

@yorkie yorkie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot You need to process the ValidateProgramCommandBufferRequest at renderer.

Copy link
Contributor Author

Copilot AI commented Sep 3, 2025

@copilot You need to process the ValidateProgramCommandBufferRequest at renderer.

Added the missing renderer processing for ValidateProgramCommandBufferRequest. The implementation includes:

  1. OnValidateProgram function that calls glValidateProgram() on the OpenGL program
  2. Command buffer handler registration for VALIDATE_PROGRAM requests
  3. Follows the same pattern as other program operations like useProgram

The validation result is stored in the GL program state and can be queried via getProgramParameter(program, gl.VALIDATE_STATUS) as expected. Changes committed in dba5df2.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • registry.npmmirror.com
    • Triggering command: npm ci (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Implement WebGL validateProgram method following MDN specification Implement WebGL validateProgram method with complete renderer processing Sep 3, 2025
Copilot AI requested a review from yorkie September 3, 2025 05:43
Copy link
Collaborator

@yorkie yorkie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Add a test page at fixtures/html/webgl-conformance

Copy link
Contributor Author

Copilot AI commented Sep 3, 2025

@copilot Add a test page at fixtures/html/webgl-conformance

Added a comprehensive test page at fixtures/html/webgl-conformance/validateprogram-test.html. The test covers:

  • API availability (validateProgram method and VALIDATE_STATUS constant)
  • Valid program validation scenarios
  • Invalid program handling
  • Error cases (null/invalid programs)
  • Integration with useProgram workflow
  • Visual pass/fail indicators with detailed test descriptions

The test page follows the existing pattern from other WebGL conformance tests and provides thorough coverage of the validateProgram implementation. Changes committed in 8ef19c4.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • registry.npmmirror.com
    • Triggering command: npm ci (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Implement WebGL validateProgram method with complete renderer processing Implement WebGL validateProgram method with complete renderer processing and test coverage Sep 3, 2025
Copilot AI requested a review from yorkie September 3, 2025 09:30
@yorkie yorkie marked this pull request as ready for review September 3, 2025 16:52
@yorkie yorkie merged commit 0b3a535 into main Sep 3, 2025
2 checks passed
@yorkie yorkie deleted the copilot/fix-e1250670-1f78-4f54-985c-c2e960a9f5f0 branch September 3, 2025 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants