Implement missing checks in WebGLRenderingContext::GetBufferParameter

This commit is contained in:
Anthony Ramine 2018-03-24 11:43:24 +01:00
parent 3525100a5f
commit 2befe47384
3 changed files with 144 additions and 12 deletions

View file

@ -1237,21 +1237,41 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
#[allow(unsafe_code)] #[allow(unsafe_code)]
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5 // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.5
unsafe fn GetBufferParameter(&self, _cx: *mut JSContext, target: u32, parameter: u32) -> JSVal { unsafe fn GetBufferParameter(
let parameter_matches = match parameter { &self,
constants::BUFFER_SIZE | _cx: *mut JSContext,
constants::BUFFER_USAGE => true, target: u32,
_ => false, parameter: u32,
) -> JSVal {
let buffer = match target {
constants::ARRAY_BUFFER => self.bound_buffer_array.get(),
constants::ELEMENT_ARRAY_BUFFER => self.bound_buffer_element_array.get(),
_ => {
self.webgl_error(InvalidEnum);
return NullValue();
}
};
match parameter {
constants::BUFFER_SIZE | constants::BUFFER_USAGE => {},
_ => {
self.webgl_error(InvalidEnum);
return NullValue();
}
}
let buffer = match buffer {
Some(buffer) => buffer,
None => {
self.webgl_error(InvalidOperation);
return NullValue();
}
}; };
if !parameter_matches { if parameter == constants::BUFFER_SIZE {
self.webgl_error(InvalidEnum); return Int32Value(buffer.capacity() as i32);
return NullValue();
} }
let (sender, receiver) = webgl_channel().unwrap(); let (sender, receiver) = webgl_channel().unwrap();
self.send_command(WebGLCommand::GetBufferParameter(target, parameter, sender)); self.send_command(WebGLCommand::GetBufferParameter(target, parameter, sender));
Int32Value(receiver.recv().unwrap()) Int32Value(receiver.recv().unwrap())
} }

View file

@ -1,3 +1,7 @@
[null-object-behaviour.html] [null-object-behaviour.html]
type: testharness [WebGL test #3: getError expected: INVALID_VALUE. Was NO_ERROR : after evaluating: context.linkProgram(undefined)]
expected: CRASH expected: FAIL
[WebGL test #38: getError expected: INVALID_OPERATION. Was INVALID_VALUE : after evaluating: context.bufferData(context.ARRAY_BUFFER, 1, context.STATIC_DRAW)]
expected: FAIL

View file

@ -1,2 +1,110 @@
[gl-object-get-calls.html] [gl-object-get-calls.html]
expected: CRASH expected: ERROR
[WebGL test #6: gl.getBufferParameter(gl.COPY_READ_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #7: gl.getBufferParameter(gl.COPY_READ_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #9: gl.getBufferParameter(gl.COPY_WRITE_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #10: gl.getBufferParameter(gl.COPY_WRITE_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #12: gl.getBufferParameter(gl.PIXEL_PACK_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #13: gl.getBufferParameter(gl.PIXEL_PACK_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #15: gl.getBufferParameter(gl.PIXEL_UNPACK_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #16: gl.getBufferParameter(gl.PIXEL_UNPACK_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #18: gl.getBufferParameter(gl.TRANSFORM_FEEDBACK_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #19: gl.getBufferParameter(gl.TRANSFORM_FEEDBACK_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #21: gl.getBufferParameter(gl.UNIFORM_BUFFER, gl.BUFFER_SIZE) should be 16 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #22: gl.getBufferParameter(gl.UNIFORM_BUFFER, gl.BUFFER_USAGE) should be 35048 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #26: getError expected: NO_ERROR. Was INVALID_ENUM : ]
expected: FAIL
[WebGL test #28: getError expected: NO_ERROR. Was INVALID_ENUM : ]
expected: FAIL
[WebGL test #29: gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be 36053. Was 36061.]
expected: FAIL
[WebGL test #35: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) should be [object WebGLRenderbuffer\]. Was null.]
expected: FAIL
[WebGL test #42: getError expected: INVALID_OPERATION. Was INVALID_ENUM : after evaluating: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE)]
expected: FAIL
[WebGL test #48: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.BACK, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) should be 33304 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #49: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) should be 33304 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #50: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.STENCIL, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) should be 33304 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #63: getError expected: NO_ERROR. Was INVALID_OPERATION : ]
expected: FAIL
[WebGL test #64: getFramebufferAttachmentParameter did not generate INVALID_ENUM for invalid parameter enum: NO_ERROR]
expected: FAIL
[WebGL test #65: getFramebufferAttachmentParameter did not generate INVALID_ENUM for invalid target enum: NO_ERROR]
expected: FAIL
[WebGL test #66: getFramebufferAttachmentParameter did not generate INVALID_ENUM for invalid attachment enum: NO_ERROR]
expected: FAIL
[WebGL test #67: getError expected: NO_ERROR. Was INVALID_ENUM : ]
expected: FAIL
[WebGL test #69: getError expected: NO_ERROR. Was INVALID_ENUM : ]
expected: FAIL
[WebGL test #70: gl.checkFramebufferStatus(gl.FRAMEBUFFER) should be 36053. Was 36061.]
expected: FAIL
[WebGL test #76: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) should be [object WebGLRenderbuffer\]. Was null.]
expected: FAIL
[WebGL test #83: getError expected: INVALID_OPERATION. Was INVALID_ENUM : after evaluating: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE)]
expected: FAIL
[WebGL test #89: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.BACK, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) should be 33304 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #90: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) should be 33304 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #91: gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.STENCIL, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) should be 0 (of type number). Was null (of type object).]
expected: FAIL
[WebGL test #104: getFramebufferAttachmentParameter did not generate INVALID_ENUM for invalid parameter enum: NO_ERROR]
expected: FAIL
[WebGL test #105: getFramebufferAttachmentParameter did not generate INVALID_ENUM for invalid target enum: NO_ERROR]
expected: FAIL
[WebGL test #106: getFramebufferAttachmentParameter did not generate INVALID_ENUM for invalid attachment enum: NO_ERROR]
expected: FAIL
[WebGL test #108: successfullyParsed should be true (of type boolean). Was undefined (of type undefined).]
expected: FAIL