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
15 changes: 15 additions & 0 deletions src/client/graphics/webgl_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2188,6 +2188,21 @@ namespace endor
sendCommandBufferRequest(req);
}

void WebGL2Context::transformFeedbackVaryings(shared_ptr<WebGLProgram> program,
const vector<string> &varyings,
uint32_t bufferMode)
{
if (program == nullptr || !program->isValid())
{
return;
}

auto commandBuffer = commandbuffers::TransformFeedbackVaryingsCommandBufferRequest(program->id,
varyings,
bufferMode);
sendCommandBufferRequest(commandBuffer);
}

void WebGL2Context::uniformBlockBinding(shared_ptr<WebGLProgram> program,
int uniformBlockIndex,
uint32_t uniformBlockBinding)
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 @@ -973,6 +973,7 @@ namespace endor
WebGLPixelType type,
unsigned char *pixels);

void transformFeedbackVaryings(std::shared_ptr<WebGLProgram> program, const std::vector<std::string> &varyings, uint32_t bufferMode);
void uniformBlockBinding(std::shared_ptr<WebGLProgram> program, int uniformBlockIndex, uint32_t uniformBlockBinding);
void uniformMatrix3x2fv(WebGLUniformLocation location, bool transpose, std::vector<float> values);
void uniformMatrix4x2fv(WebGLUniformLocation location, bool transpose, std::vector<float> values);
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
60 changes: 58 additions & 2 deletions src/client/script_bindings/webgl/webgl2_rendering_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,9 +993,65 @@ namespace endor
{
Isolate *isolate = args.GetIsolate();
HandleScope scope(isolate);
Local<Context> context = isolate->GetCurrentContext();

isolate->ThrowException(Exception::Error(
MakeMethodError(isolate, "transformFeedbackVaryings", "Not implemented")));
if (args.Length() < 3)
{
isolate->ThrowException(Exception::TypeError(
MakeMethodArgCountError(isolate, "transformFeedbackVaryings", 3, args.Length())));
return;
}
if (!WebGLProgram::IsInstanceOf(isolate, args[0]))
{
isolate->ThrowException(Exception::TypeError(
MakeMethodArgTypeError(isolate, "transformFeedbackVaryings", 0, "WebGLProgram", args[0])));
return;
}
if (!args[1]->IsArray())
{
isolate->ThrowException(Exception::TypeError(
MakeMethodArgTypeError(isolate, "transformFeedbackVaryings", 1, "Array", args[1])));
return;
}
if (!args[2]->IsNumber())
{
isolate->ThrowException(Exception::TypeError(
MakeMethodArgTypeError(isolate, "transformFeedbackVaryings", 2, "number", args[2])));
return;
}

auto programObj = args[0].As<Object>();
auto program = WebGLProgram::Unwrap(isolate, programObj);
if (program == nullptr || !program->hasData())
{
isolate->ThrowException(Exception::TypeError(
MakeMethodError(isolate, "transformFeedbackVaryings", "Invalid WebGLProgram")));
return;
}

// Extract varyings array
vector<string> varyings;
Local<Array> varyingsArray = args[1].As<Array>();
uint32_t length = varyingsArray->Length();
varyings.reserve(length);

for (uint32_t i = 0; i < length; ++i)
{
Local<Value> item = varyingsArray->Get(context, i).ToLocalChecked();
if (!item->IsString())
{
isolate->ThrowException(Exception::TypeError(
MakeMethodError(isolate, "transformFeedbackVaryings", "All varyings must be strings")));
return;
}
String::Utf8Value utf8Value(isolate, item);
varyings.push_back(string(*utf8Value));
}

uint32_t bufferMode = args[2]->Uint32Value(context).ToChecked();

handle()->transformFeedbackVaryings(program->handle(), varyings, bufferMode);
args.GetReturnValue().SetUndefined();
}

void WebGL2RenderingContext::GetTransformFeedbackVarying(const FunctionCallbackInfo<Value> &args)
Expand Down
65 changes: 65 additions & 0 deletions src/common/command_buffers/details/program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,4 +494,69 @@ namespace commandbuffers
public:
std::string infoLog;
};

class TransformFeedbackVaryingsCommandBufferRequest final
: public TrCommandBufferSimpleRequest<TransformFeedbackVaryingsCommandBufferRequest,
COMMAND_BUFFER_TRANSFORM_FEEDBACK_VARYINGS_REQ>
{
public:
TransformFeedbackVaryingsCommandBufferRequest() = delete;
TransformFeedbackVaryingsCommandBufferRequest(uint32_t program, const std::vector<std::string> &varyings, uint32_t bufferMode)
: TrCommandBufferSimpleRequest()
, program(program)
, varyings(varyings)
, bufferMode(bufferMode)
{
}
TransformFeedbackVaryingsCommandBufferRequest(const TransformFeedbackVaryingsCommandBufferRequest &that, bool clone = false)
: TrCommandBufferSimpleRequest(that, clone)
, program(that.program)
, varyings(that.varyings)
, bufferMode(that.bufferMode)
{
}

std::string toString(const char *line_prefix) const override
{
std::stringstream ss;
ss << TrCommandBufferSimpleRequest::toString(line_prefix) << "(" << program << ", [";
for (size_t i = 0; i < varyings.size(); i++)
{
if (i > 0)
ss << ", ";
ss << varyings[i];
}
ss << "], " << bufferMode << ")";
return ss.str();
}

TrCommandBufferMessage *serialize() override
{
auto message = new TrCommandBufferMessage(type, size, this);
// Serialize the varyings array
for (const auto &varying : varyings)
{
message->addStringSegment(const_cast<std::string &>(varying));
}
return message;
}

void deserialize(TrCommandBufferMessage &message) override
{
varyings.clear();
for (size_t i = 0; i < message.getSegmentCount(); i++)
{
auto segment = message.getSegment(i);
if (segment != nullptr)
{
varyings.push_back(segment->toString());
}
}
}

public:
uint32_t program;
std::vector<std::string> varyings;
uint32_t bufferMode;
};
}
1 change: 1 addition & 0 deletions src/common/command_buffers/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
XX(VERTEX_ATTRIB_I4IV, VertexAttribI4ivCommandBufferRequest, "GL::VertexAttribI4iv") \
XX(VERTEX_ATTRIB_I4UIV, VertexAttribI4uivCommandBufferRequest, "GL::VertexAttribI4uiv") \
XX(UNIFORM_BLOCK_BINDING, UniformBlockBindingCommandBufferRequest, "GL::UniformBlockBinding") \
XX(TRANSFORM_FEEDBACK_VARYINGS, TransformFeedbackVaryingsCommandBufferRequest, "GL::TransformFeedbackVaryings") \
XX(UNIFORM1F, Uniform1fCommandBufferRequest, "GL::Uniform1f") \
XX(UNIFORM1FV, Uniform1fvCommandBufferRequest, "GL::Uniform1fv") \
XX(UNIFORM1I, Uniform1iCommandBufferRequest, "GL::Uniform1i") \
Expand Down
21 changes: 21 additions & 0 deletions src/renderer/render_api_opengles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,26 @@ 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 OnTransformFeedbackVaryings(TransformFeedbackVaryingsCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
{
auto &glObjectManager = reqContentRenderer->getContextGL()->ObjectManagerRef();
auto program = glObjectManager.FindProgram(req->program);

// Convert vector of strings to array of C strings for OpenGL API
std::vector<const char *> varyings;
varyings.reserve(req->varyings.size());
for (const auto &varying : req->varyings)
{
varyings.push_back(varying.c_str());
}

glTransformFeedbackVaryings(program, static_cast<GLsizei>(varyings.size()), varyings.data(), req->bufferMode);

if (TR_UNLIKELY(CheckError(req, reqContentRenderer) != GL_NO_ERROR || options.printsCall))
PrintDebugInfo(req, nullptr, nullptr, options);
}
TR_OPENGL_FUNC void OnUniform1f(Uniform1fCommandBufferRequest *req,
renderer::TrContentRenderer *reqContentRenderer,
ApiCallOptions &options)
Expand Down Expand Up @@ -2937,6 +2957,7 @@ bool RHI_OpenGL::ExecuteCommandBuffer(vector<commandbuffers::TrCommandBufferBase
ADD_COMMAND_BUFFER_HANDLER(VERTEX_ATTRIB_I4IV, VertexAttribI4ivCommandBufferRequest, VertexAttribI4iv)
ADD_COMMAND_BUFFER_HANDLER(VERTEX_ATTRIB_I4UIV, VertexAttribI4uivCommandBufferRequest, VertexAttribI4uiv)
ADD_COMMAND_BUFFER_HANDLER(UNIFORM_BLOCK_BINDING, UniformBlockBindingCommandBufferRequest, UniformBlockBinding)
ADD_COMMAND_BUFFER_HANDLER(TRANSFORM_FEEDBACK_VARYINGS, TransformFeedbackVaryingsCommandBufferRequest, TransformFeedbackVaryings)
ADD_COMMAND_BUFFER_HANDLER(UNIFORM1F, Uniform1fCommandBufferRequest, Uniform1f)
ADD_COMMAND_BUFFER_HANDLER(UNIFORM1FV, Uniform1fvCommandBufferRequest, Uniform1fv)
ADD_COMMAND_BUFFER_HANDLER(UNIFORM1I, Uniform1iCommandBufferRequest, Uniform1i)
Expand Down
Loading