Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/client/graphics/webgl_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1639,6 +1639,7 @@ namespace endor
maxVertexUniformBlocks = initResp->maxVertexUniformBlocks;
maxVertexUniformComponents = initResp->maxVertexUniformComponents;
minProgramTexelOffset = initResp->minProgramTexelOffset;
uniformBufferOffsetAlignment = 1; // Will be queried on first access
maxClientWaitTimeout = initResp->maxClientWaitTimeout;
maxCombinedFragmentUniformComponents = initResp->maxCombinedFragmentUniformComponents;
maxCombinedVertexUniformComponents = initResp->maxCombinedVertexUniformComponents;
Expand Down Expand Up @@ -2023,6 +2024,22 @@ namespace endor
return maxUniformBlockSize;
else if (pname == WebGL2IntegerParameterName::kMaxTextureLodBias)
return maxTextureLODBias;
else if (pname == WebGL2IntegerParameterName::kUniformBufferOffsetAlignment)
{
// Query once and cache
if (uniformBufferOffsetAlignment == 1)
{
auto req = GetIntegervCommandBufferRequest(static_cast<uint32_t>(pname));
sendCommandBufferRequest(req, true);
auto resp = recvResponse<GetIntegervCommandBufferResponse>(COMMAND_BUFFER_GET_INTEGERV_RES, req);
if (resp != nullptr)
{
uniformBufferOffsetAlignment = resp->value;
delete resp;
}
}
return uniformBufferOffsetAlignment;
}
else if (pname == WebGL2IntegerParameterName::kExtMaxViewsOvr)
return OVR_maxViews;

Expand All @@ -2038,6 +2055,22 @@ namespace endor
return v;
}

bool WebGL2Context::getParameterV2(WebGL2BooleanParameterName pname)
{
auto req = GetBooleanvCommandBufferRequest(static_cast<uint32_t>(pname));
sendCommandBufferRequest(req, true);

auto resp = recvResponse<GetBooleanvCommandBufferResponse>(COMMAND_BUFFER_GET_BOOLEANV_RES, req);
if (resp == nullptr) [[unlikely]]
{
string msg = "Failed to get boolean parameter(" + to_string(static_cast<uint32_t>(pname)) + "): timeout.";
throw runtime_error(msg);
}
auto v = resp->value;
delete resp;
return v;
}

shared_ptr<WebGLQuery> WebGL2Context::getQuery(WebGLQueryTarget target, int pname)
{
NOT_IMPLEMENTED();
Expand Down
10 changes: 10 additions & 0 deletions src/client/graphics/webgl_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ namespace endor
kDepthWrite = WEBGL_DEPTH_WRITEMASK,
kDither = WEBGL_DITHER,
kPolygonOffsetFill = WEBGL_POLYGON_OFFSET_FILL,
kSampleAlphaToCoverage = WEBGL_SAMPLE_ALPHA_TO_COVERAGE,
kSampleCoverage = WEBGL_SAMPLE_COVERAGE,
kSampleCoverageInvert = WEBGL_SAMPLE_COVERAGE_INVERT,
kScissorTest = WEBGL_SCISSOR_TEST,
kStencilTest = WEBGL_STENCIL_TEST,
Expand Down Expand Up @@ -186,6 +188,11 @@ namespace endor
kVersion = WEBGL_VERSION,
};

enum class WebGL2BooleanParameterName
{
kRasterizerDiscard = WEBGL2_RASTERIZER_DISCARD,
};

enum class WebGL2IntegerParameterName
{
kMax3DTextureSize = WEBGL2_MAX_3D_TEXTURE_SIZE,
Expand Down Expand Up @@ -216,6 +223,7 @@ namespace endor
kMaxServerWaitTimeout = WEBGL2_MAX_SERVER_WAIT_TIMEOUT,
kMaxUniformBlockSize = WEBGL2_MAX_UNIFORM_BLOCK_SIZE,
kMaxTextureLodBias = WEBGL2_MAX_TEXTURE_LOD_BIAS,
kUniformBufferOffsetAlignment = WEBGL2_UNIFORM_BUFFER_OFFSET_ALIGNMENT,
kExtMaxViewsOvr = WEBGL2_EXT_MAX_VIEWS_OVR,
};

Expand Down Expand Up @@ -917,6 +925,7 @@ namespace endor
std::optional<int> length = std::nullopt);
int getFragDataLocation(std::shared_ptr<WebGLProgram> program, const std::string &name);
int getParameterV2(WebGL2IntegerParameterName pname);
bool getParameterV2(WebGL2BooleanParameterName pname);
std::shared_ptr<WebGLQuery> getQuery(WebGLQueryTarget target, int pname);
int getUniformBlockIndex(std::shared_ptr<WebGLProgram> program, const std::string &uniformBlockName);

Expand Down Expand Up @@ -1020,6 +1029,7 @@ namespace endor
int maxVertexUniformBlocks;
int maxVertexUniformComponents;
int minProgramTexelOffset;
int uniformBufferOffsetAlignment;
int64_t maxClientWaitTimeout;
int64_t maxCombinedFragmentUniformComponents;
int64_t maxCombinedVertexUniformComponents;
Expand Down
2 changes: 1 addition & 1 deletion src/client/script_bindings/webgl/active_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ namespace endor
}

} // namespace webgl
} // namespace script_bindings
} // namespace script_bindings
} // namespace endor
2 changes: 1 addition & 1 deletion src/client/script_bindings/webgl/active_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ namespace endor
};

} // namespace webgl
} // namespace script_bindings
} // namespace script_bindings
} // namespace endor
2 changes: 1 addition & 1 deletion src/client/script_bindings/webgl/framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ namespace endor
{
}
} // namespace webgl
} // namespace script_bindings
} // namespace script_bindings
} // namespace endor
2 changes: 1 addition & 1 deletion src/client/script_bindings/webgl/framebuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ namespace endor
};

} // namespace webgl
} // namespace script_bindings
} // namespace script_bindings
} // namespace endor
2 changes: 1 addition & 1 deletion src/client/script_bindings/webgl/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ namespace endor
// WebGLObject is a base class, typically not instantiated directly
}
} // namespace webgl
} // namespace script_bindings
} // namespace script_bindings
} // namespace endor
2 changes: 1 addition & 1 deletion src/client/script_bindings/webgl/object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ namespace endor
};

} // namespace webgl
} // namespace script_bindings
} // namespace script_bindings
} // namespace endor
2 changes: 1 addition & 1 deletion src/client/script_bindings/webgl/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ namespace endor
}

} // namespace webgl
} // namespace script_bindings
} // namespace script_bindings
} // namespace endor
2 changes: 1 addition & 1 deletion src/client/script_bindings/webgl/program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ namespace endor
WebGLProgram(v8::Isolate *isolate, const v8::FunctionCallbackInfo<v8::Value> &args);
};
} // namespace webgl
} // namespace script_bindings
} // namespace script_bindings
} // namespace endor
2 changes: 1 addition & 1 deletion src/client/script_bindings/webgl/renderbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ namespace endor
// WebGLRenderbuffer objects are created by WebGL context, not by user code
}
} // namespace webgl
} // namespace script_bindings
} // namespace script_bindings
} // namespace endor
2 changes: 1 addition & 1 deletion src/client/script_bindings/webgl/renderbuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ namespace endor
};

} // namespace webgl
} // namespace script_bindings
} // namespace script_bindings
} // namespace endor
2 changes: 1 addition & 1 deletion src/client/script_bindings/webgl/texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ namespace endor
{
}
} // namespace webgl
} // namespace script_bindings
} // namespace script_bindings
} // namespace endor
2 changes: 1 addition & 1 deletion src/client/script_bindings/webgl/texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ namespace endor
};

} // namespace webgl
} // namespace script_bindings
} // namespace script_bindings
} // namespace endor
2 changes: 1 addition & 1 deletion src/client/script_bindings/webgl/uniform_location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ namespace endor
}

} // namespace webgl
} // namespace script_bindings
} // namespace script_bindings
} // namespace endor
2 changes: 1 addition & 1 deletion src/client/script_bindings/webgl/uniform_location.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ namespace endor
};

} // namespace webgl
} // namespace script_bindings
} // namespace script_bindings
} // namespace endor
2 changes: 1 addition & 1 deletion src/client/script_bindings/webgl/vertex_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ namespace endor
{
}
} // namespace webgl
} // namespace script_bindings
} // namespace script_bindings
} // namespace endor
2 changes: 1 addition & 1 deletion src/client/script_bindings/webgl/vertex_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ namespace endor
};

} // namespace webgl
} // namespace script_bindings
} // namespace script_bindings
} // namespace endor
11 changes: 11 additions & 0 deletions src/client/script_bindings/webgl/webgl_rendering_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4348,6 +4348,8 @@ namespace endor
case WEBGL_DEPTH_WRITEMASK:
case WEBGL_DITHER:
case WEBGL_POLYGON_OFFSET_FILL:
case WEBGL_SAMPLE_ALPHA_TO_COVERAGE:
case WEBGL_SAMPLE_COVERAGE:
case WEBGL_SAMPLE_COVERAGE_INVERT:
case WEBGL_SCISSOR_TEST:
case WEBGL_STENCIL_TEST:
Expand Down Expand Up @@ -4395,6 +4397,7 @@ namespace endor
{
switch (pname)
{
case WEBGL2_MAX_3D_TEXTURE_SIZE:
case WEBGL2_MAX_ARRAY_TEXTURE_LAYERS:
case WEBGL2_MAX_COLOR_ATTACHMENTS:
case WEBGL2_MAX_COMBINED_UNIFORM_BLOCKS:
Expand Down Expand Up @@ -4422,13 +4425,21 @@ namespace endor
case WEBGL2_MAX_SERVER_WAIT_TIMEOUT:
case WEBGL2_MAX_UNIFORM_BLOCK_SIZE:
case WEBGL2_MAX_TEXTURE_LOD_BIAS:
case WEBGL2_UNIFORM_BUFFER_OFFSET_ALIGNMENT:
case WEBGL2_EXT_MAX_VIEWS_OVR:
{
auto value = handle<client_graphics::WebGL2Context>()
->getParameterV2(static_cast<client_graphics::WebGL2IntegerParameterName>(pname));
jsValue = Integer::New(isolate, value);
break;
}
case WEBGL2_RASTERIZER_DISCARD:
{
jsValue = Boolean::New(isolate,
handle<client_graphics::WebGL2Context>()
->getParameterV2(static_cast<client_graphics::WebGL2BooleanParameterName>(pname)));
break;
}
default:
break;
}
Expand Down