Skip to content
Open
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
16 changes: 16 additions & 0 deletions src/client/graphics/webgl_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1968,6 +1968,22 @@ namespace endor
return -1;
}

vector<int> WebGL2Context::getInternalformatParameter(uint32_t target, uint32_t internalformat, uint32_t pname)
{
// Query the underlying GL implementation via command buffer
auto req = GetInternalformatParameterCommandBufferRequest(target, internalformat, pname);
sendCommandBufferRequest(req, true);
auto response = recvResponse<GetInternalformatParameterCommandBufferResponse>(
COMMAND_BUFFER_GET_INTERNALFORMAT_PARAMETER_RES,
req);

if (response == nullptr) [[unlikely]]
{
throw runtime_error("Failed to get internal format parameter: timeout.");
}
return response->values;
}

int WebGL2Context::getParameterV2(WebGL2IntegerParameterName pname)
{
/**
Expand Down
1 change: 1 addition & 0 deletions src/client/graphics/webgl_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ namespace endor
std::optional<int> dstOffset = std::nullopt,
std::optional<int> length = std::nullopt);
int getFragDataLocation(std::shared_ptr<WebGLProgram> program, const std::string &name);
std::vector<int> getInternalformatParameter(uint32_t target, uint32_t internalformat, uint32_t pname);
int getParameterV2(WebGL2IntegerParameterName pname);
std::shared_ptr<WebGLQuery> getQuery(WebGLQueryTarget target, int pname);
int getUniformBlockIndex(std::shared_ptr<WebGLProgram> program, const std::string &uniformBlockName);
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
51 changes: 51 additions & 0 deletions src/client/script_bindings/webgl/webgl2_rendering_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ namespace endor
// Enhanced framebuffer operations
ADD_WEBGL2_METHOD("blitFramebuffer", BlitFramebuffer)
ADD_WEBGL2_METHOD("renderbufferStorageMultisample", RenderbufferStorageMultisample)
ADD_WEBGL2_METHOD("getInternalformatParameter", GetInternalformatParameter)
ADD_WEBGL2_METHOD("framebufferTextureLayer", FramebufferTextureLayer)

// Enhanced texture operations
Expand Down Expand Up @@ -1703,6 +1704,56 @@ namespace endor
args.GetReturnValue().SetUndefined();
}

void WebGL2RenderingContext::GetInternalformatParameter(const FunctionCallbackInfo<Value> &args)
{
Isolate *isolate = args.GetIsolate();
HandleScope scope(isolate);
Local<Context> context = isolate->GetCurrentContext();

if (args.Length() < 3)
{
isolate->ThrowException(Exception::TypeError(
MakeMethodArgCountError(isolate, "getInternalformatParameter", 3, args.Length())));
return;
}

for (int i = 0; i < 3; ++i)
{
if (!args[i]->IsNumber())
{
isolate->ThrowException(Exception::TypeError(
MakeMethodArgTypeError(isolate, "getInternalformatParameter", i, "number", args[i])));
return;
}
}

uint32_t target = args[0]->Uint32Value(context).ToChecked();
uint32_t internalformat = args[1]->Uint32Value(context).ToChecked();
uint32_t pname = args[2]->Uint32Value(context).ToChecked();

// Delegate to WebGL2Context for the actual query
auto values = handle()->getInternalformatParameter(target, internalformat, pname);

// If empty vector returned, it means unsupported pname - return null per spec
if (values.empty())
{
args.GetReturnValue().SetNull();
return;
}

// Create Int32Array to return the values
auto arraybuffer = ArrayBuffer::New(isolate, sizeof(int32_t) * values.size());
auto backingStore = arraybuffer->GetBackingStore();
int32_t *data = static_cast<int32_t *>(backingStore->Data());
for (size_t i = 0; i < values.size(); i++)
{
data[i] = values[i];
}

Local<Value> result = Int32Array::New(arraybuffer, 0, values.size());
args.GetReturnValue().Set(result);
}

void WebGL2RenderingContext::FramebufferTextureLayer(const v8::FunctionCallbackInfo<v8::Value> &args)
{
Isolate *isolate = args.GetIsolate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ namespace endor
// Enhanced framebuffer operations
void BlitFramebuffer(const v8::FunctionCallbackInfo<v8::Value> &args);
void RenderbufferStorageMultisample(const v8::FunctionCallbackInfo<v8::Value> &args);
void GetInternalformatParameter(const v8::FunctionCallbackInfo<v8::Value> &args);
void FramebufferTextureLayer(const v8::FunctionCallbackInfo<v8::Value> &args);

// Enhanced texture operations
Expand Down
72 changes: 72 additions & 0 deletions src/common/command_buffers/details/properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,76 @@ namespace commandbuffers
public:
int error;
};

class GetInternalformatParameterCommandBufferRequest final
: public TrCommandBufferSimpleRequest<GetInternalformatParameterCommandBufferRequest,
COMMAND_BUFFER_GET_INTERNALFORMAT_PARAMETER_REQ>
{
public:
GetInternalformatParameterCommandBufferRequest() = delete;
GetInternalformatParameterCommandBufferRequest(uint32_t target, uint32_t internalformat, uint32_t pname)
: TrCommandBufferSimpleRequest()
, target(target)
, internalformat(internalformat)
, pname(pname)
{
}
GetInternalformatParameterCommandBufferRequest(const GetInternalformatParameterCommandBufferRequest &that,
bool clone = false)
: TrCommandBufferSimpleRequest(that, clone)
, target(that.target)
, internalformat(that.internalformat)
, pname(that.pname)
{
}

public:
uint32_t target;
uint32_t internalformat;
uint32_t pname;
};

class GetInternalformatParameterCommandBufferResponse final
: public TrCommandBufferSimpleResponse<GetInternalformatParameterCommandBufferResponse>
{
public:
GetInternalformatParameterCommandBufferResponse() = delete;
GetInternalformatParameterCommandBufferResponse(GetInternalformatParameterCommandBufferRequest *req,
const std::vector<int> &values)
: TrCommandBufferSimpleResponse(COMMAND_BUFFER_GET_INTERNALFORMAT_PARAMETER_RES, req)
, values(values)
{
}
GetInternalformatParameterCommandBufferResponse(const GetInternalformatParameterCommandBufferResponse &that,
bool clone = false)
: TrCommandBufferSimpleResponse(that, clone)
{
if (clone)
values = that.values;
}

public:
TrCommandBufferMessage *serialize() override
{
auto message = new TrCommandBufferMessage(type, size, this);
if (values.size() > 0)
{
// Serialize the vector using addVecSegment
message->addVecSegment(values);
}
return message;
}

void deserialize(TrCommandBufferMessage &message) override
{
auto valuesSegment = message.nextSegment();
if (valuesSegment != nullptr)
values = valuesSegment->toVec<int>();
else
values.clear();
}

public:
std::vector<int> values;
};
}
4 changes: 3 additions & 1 deletion src/common/command_buffers/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
XX(SAMPLER_PARAMETERF, SamplerParameterfCommandBufferRequest, "GL::SamplerParameterf") \
XX(GET_SAMPLER_PARAMETER, GetSamplerParameterCommandBufferRequest, "GL::GetSamplerParameter") \
XX(IS_SAMPLER, IsSamplerCommandBufferRequest, "GL::IsSampler") \
XX(GET_INTERNALFORMAT_PARAMETER, GetInternalformatParameterCommandBufferRequest, "GL::GetInternalformatParameter") \
XX(XRFRAME_START, XRFrameStartCommandBufferRequest, "XR::FrameStart") \
XX(XRFRAME_FLUSH, XRFrameFlushCommandBufferRequest, "XR::FrameFlush") \
XX(XRFRAME_END, XRFrameEndCommandBufferRequest, "XR::FrameEnd") \
Expand All @@ -171,4 +172,5 @@
XX(GET_FLOATV, GetFloatvCommandBufferResponse, "GL::GetFloatv") \
XX(GET_STRING, GetStringCommandBufferResponse, "GL::GetString") \
XX(GET_SHADER_PRECISION_FORMAT, GetShaderPrecisionFormatCommandBufferResponse, "GL::GetShaderPrecisionFormat") \
XX(GET_ERROR, GetErrorCommandBufferResponse, "GL::GetError")
XX(GET_ERROR, GetErrorCommandBufferResponse, "GL::GetError") \
XX(GET_INTERNALFORMAT_PARAMETER, GetInternalformatParameterCommandBufferResponse, "GL::GetInternalformatParameter")
2 changes: 2 additions & 0 deletions src/common/command_buffers/shared.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ namespace commandbuffers
COMMAND_BUFFER_GET_SHADER_PRECISION_FORMAT_RES,
COMMAND_BUFFER_GET_ERROR_REQ,
COMMAND_BUFFER_GET_ERROR_RES,
COMMAND_BUFFER_GET_INTERNALFORMAT_PARAMETER_REQ,
COMMAND_BUFFER_GET_INTERNALFORMAT_PARAMETER_RES,

/** XRFrame controls */
COMMAND_BUFFER_XRFRAME_START_REQ,
Expand Down
1 change: 1 addition & 0 deletions src/common/command_buffers/webgl_constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ const int WEBGL_TEXTURE_BINDING_2D = 0x8069;
const int WEBGL_SAMPLE_BUFFERS = 0x80A8;
const int WEBGL_SAMPLES = 0x80A9;
const int WEBGL_SAMPLE_COVERAGE_VALUE = 0x80AA;
const int GL_NUM_SAMPLE_COUNTS = 0x9380;
const int WEBGL_SAMPLE_COVERAGE_INVERT = 0x80AB;
const int WEBGL_COMPRESSED_TEXTURE_FORMATS = 0x86A3;
const int WEBGL_VENDOR = 0x1F00;
Expand Down
Loading