Skip to content
Merged
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
7 changes: 6 additions & 1 deletion src/client/graphics/webgl_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,12 @@ namespace endor
int level,
int layer)
{
NOT_IMPLEMENTED();
auto req = FramebufferTextureLayerCommandBufferRequest(static_cast<uint32_t>(target),
static_cast<uint32_t>(attachment),
texture != nullptr ? texture->id : 0,
level,
layer);
sendCommandBufferRequest(req);
}

string WebGL2Context::getActiveUniformBlockName(shared_ptr<WebGLProgram> program, int uniformBlockIndex)
Expand Down
77 changes: 77 additions & 0 deletions src/client/script_bindings/webgl/webgl2_rendering_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "./buffer.hpp"
#include "./program.hpp"
#include "./vertex_array.hpp"
#include "./texture.hpp"

namespace endor
{
Expand Down Expand Up @@ -417,6 +418,7 @@ namespace endor
// Enhanced framebuffer operations
ADD_WEBGL2_METHOD("blitFramebuffer", BlitFramebuffer)
ADD_WEBGL2_METHOD("renderbufferStorageMultisample", RenderbufferStorageMultisample)
ADD_WEBGL2_METHOD("framebufferTextureLayer", FramebufferTextureLayer)

// Enhanced texture operations
ADD_WEBGL2_METHOD("texImage3D", TexImage3D)
Expand Down Expand Up @@ -1701,6 +1703,81 @@ namespace endor
args.GetReturnValue().SetUndefined();
}

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

if (args.Length() < 5)
{
isolate->ThrowException(Exception::TypeError(
MakeMethodArgCountError(isolate, "framebufferTextureLayer", 5, args.Length())));
return;
}
if (!args[0]->IsNumber())
{
isolate->ThrowException(Exception::TypeError(
MakeMethodArgTypeError(isolate, "framebufferTextureLayer", 0, "number", args[0])));
return;
}
if (!args[1]->IsNumber())
{
isolate->ThrowException(Exception::TypeError(
MakeMethodArgTypeError(isolate, "framebufferTextureLayer", 1, "number", args[1])));
return;
}
if (!args[2]->IsNull() && !WebGLTexture::IsInstanceOf(isolate, args[2]))
{
isolate->ThrowException(Exception::TypeError(
MakeMethodArgTypeError(isolate, "framebufferTextureLayer", 2, "WebGLTexture or null", args[2])));
return;
}
if (!args[3]->IsNumber())
{
isolate->ThrowException(Exception::TypeError(
MakeMethodArgTypeError(isolate, "framebufferTextureLayer", 3, "number", args[3])));
return;
}
if (!args[4]->IsNumber())
{
isolate->ThrowException(Exception::TypeError(
MakeMethodArgTypeError(isolate, "framebufferTextureLayer", 4, "number", args[4])));
return;
}

client_graphics::WebGLFramebufferBindingTarget target;
{
int value = args[0]->Int32Value(context).ToChecked();
target = static_cast<client_graphics::WebGLFramebufferBindingTarget>(value);
}
client_graphics::WebGLFramebufferAttachment attachment;
{
int value = args[1]->Int32Value(context).ToChecked();
attachment = static_cast<client_graphics::WebGLFramebufferAttachment>(value);
}
int level = args[3]->Int32Value(context).ToChecked();
int layer = args[4]->Int32Value(context).ToChecked();

if (args[2]->IsNull())
{
handle()->framebufferTextureLayer(target, attachment, nullptr, level, layer);
}
else
{
auto textureObj = args[2].As<Object>();
auto textureBinding = WebGLTexture::Unwrap(isolate, textureObj);
if (textureBinding == nullptr || !textureBinding->hasData())
{
isolate->ThrowException(Exception::TypeError(
MakeMethodError(isolate, "framebufferTextureLayer", "Invalid WebGLTexture object")));
return;
}
handle()->framebufferTextureLayer(target, attachment, textureBinding->handle(), level, layer);
}
args.GetReturnValue().SetUndefined();
}

// Enhanced texture operations
void WebGL2RenderingContext::TexImage3D(const FunctionCallbackInfo<Value> &args)
{
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 FramebufferTextureLayer(const v8::FunctionCallbackInfo<v8::Value> &args);

// Enhanced texture operations
void TexImage3D(const v8::FunctionCallbackInfo<v8::Value> &args);
Expand Down
46 changes: 46 additions & 0 deletions src/common/command_buffers/details/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,52 @@ namespace commandbuffers
uint32_t level;
};

class FramebufferTextureLayerCommandBufferRequest final
: public TrCommandBufferSimpleRequest<FramebufferTextureLayerCommandBufferRequest,
COMMAND_BUFFER_FRAMEBUFFER_TEXTURE_LAYER_REQ>
{
public:
FramebufferTextureLayerCommandBufferRequest() = delete;
FramebufferTextureLayerCommandBufferRequest(uint32_t target, uint32_t attachment, uint32_t texture, uint32_t level, uint32_t layer)
: TrCommandBufferSimpleRequest()
, target(target)
, attachment(attachment)
, texture(texture)
, level(level)
, layer(layer)
{
}
FramebufferTextureLayerCommandBufferRequest(const FramebufferTextureLayerCommandBufferRequest &that, bool clone = false)
: TrCommandBufferSimpleRequest(that, clone)
, target(that.target)
, attachment(that.attachment)
, texture(that.texture)
, level(that.level)
, layer(that.layer)
{
}

std::string toString(const char *line_prefix) const override
{
std::stringstream ss;
ss << TrCommandBufferSimpleRequest::toString(line_prefix) << "("
<< WebGLHelper::WebGLEnumToString(target) << ", "
<< "attachment=" << WebGLHelper::WebGLFramebufferAttachmentToString(attachment) << ", "
<< "texture=" << texture << ", "
<< "level=" << level << ", "
<< "layer=" << layer
<< ")";
return ss.str();
}

public:
uint32_t target;
uint32_t attachment;
uint32_t texture;
uint32_t level;
uint32_t layer;
};

class CheckFramebufferStatusCommandBufferRequest final
: public TrCommandBufferSimpleRequest<CheckFramebufferStatusCommandBufferRequest,
COMMAND_BUFFER_CHECK_FRAMEBUFFER_STATUS_REQ>
Expand Down
1 change: 1 addition & 0 deletions src/common/command_buffers/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
XX(BIND_FRAMEBUFFER, BindFramebufferCommandBufferRequest, "GL::BindFramebuffer") \
XX(FRAMEBUFFER_RENDERBUFFER, FramebufferRenderbufferCommandBufferRequest, "GL::FramebufferRenderbuffer") \
XX(FRAMEBUFFER_TEXTURE2D, FramebufferTexture2DCommandBufferRequest, "GL::FramebufferTexture2D") \
XX(FRAMEBUFFER_TEXTURE_LAYER, FramebufferTextureLayerCommandBufferRequest, "GL::FramebufferTextureLayer") \
XX(CHECK_FRAMEBUFFER_STATUS, CheckFramebufferStatusCommandBufferRequest, "GL::CheckFramebufferStatus") \
XX(CREATE_RENDERBUFFER, CreateRenderbufferCommandBufferRequest, "GL::CreateRenderbuffer") \
XX(DELETE_RENDERBUFFER, DeleteRenderbufferCommandBufferRequest, "GL::DeleteRenderbuffer") \
Expand Down
1 change: 1 addition & 0 deletions src/common/command_buffers/shared.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ namespace commandbuffers
COMMAND_BUFFER_BIND_FRAMEBUFFER_REQ,
COMMAND_BUFFER_FRAMEBUFFER_RENDERBUFFER_REQ,
COMMAND_BUFFER_FRAMEBUFFER_TEXTURE2D_REQ,
COMMAND_BUFFER_FRAMEBUFFER_TEXTURE_LAYER_REQ,
COMMAND_BUFFER_CHECK_FRAMEBUFFER_STATUS_REQ,
COMMAND_BUFFER_CHECK_FRAMEBUFFER_STATUS_RES,
COMMAND_BUFFER_CREATE_RENDERBUFFER_REQ,
Expand Down
18 changes: 18 additions & 0 deletions src/renderer/render_api_opengles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,23 @@ class RHI_OpenGL : public TrRenderHardwareInterface
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, nullptr, options);
}

TR_OPENGL_FUNC void OnFramebufferTextureLayer(FramebufferTextureLayerCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto &glObjectManager = reqContentRenderer->getContextGL()->ObjectManagerRef();
auto target = req->target;
auto attachment = req->attachment;
auto texture = glObjectManager.FindTexture(req->texture);
auto level = req->level;
auto layer = req->layer;

glFramebufferTextureLayer(target, attachment, texture, level, layer);
if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, nullptr, options);
}

TR_OPENGL_FUNC void OnCheckFramebufferStatus(CheckFramebufferStatusCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
Expand Down Expand Up @@ -2899,6 +2916,7 @@ bool RHI_OpenGL::ExecuteCommandBuffer(vector<commandbuffers::TrCommandBufferBase
ADD_COMMAND_BUFFER_HANDLER(BIND_FRAMEBUFFER, BindFramebufferCommandBufferRequest, BindFramebuffer)
ADD_COMMAND_BUFFER_HANDLER(FRAMEBUFFER_RENDERBUFFER, FramebufferRenderbufferCommandBufferRequest, FramebufferRenderbuffer)
ADD_COMMAND_BUFFER_HANDLER(FRAMEBUFFER_TEXTURE2D, FramebufferTexture2DCommandBufferRequest, FramebufferTexture2D)
ADD_COMMAND_BUFFER_HANDLER(FRAMEBUFFER_TEXTURE_LAYER, FramebufferTextureLayerCommandBufferRequest, FramebufferTextureLayer)
ADD_COMMAND_BUFFER_HANDLER(CHECK_FRAMEBUFFER_STATUS, CheckFramebufferStatusCommandBufferRequest, CheckFramebufferStatus)
ADD_COMMAND_BUFFER_HANDLER(CREATE_RENDERBUFFER, CreateRenderbufferCommandBufferRequest, CreateRenderbuffer)
ADD_COMMAND_BUFFER_HANDLER(DELETE_RENDERBUFFER, DeleteRenderbufferCommandBufferRequest, DeleteRenderbuffer)
Expand Down