Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

problem with integer geometry attributes and batched shader execution

Đang mở
#1,929 6 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@AlexMWells đang làm issue này rồi.

Từ ngày 8/2/2025.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

batch shading

I'm seeing a problem with batched execution that I've managed to distill to the repro case below with testshade. Basically, if I have an integer geometry attribute, then batched OSL execution seems to disregard what the renderer writes to the destination depending on what the default value is specified in the shader. For eample, suppose I have a shader with the following parameter declaration, int face_idx = 0 [[int lockgeom=0]], the value returned by the renderer doesn't make it to the shader. But in this case it does: face_idx = 2 [[int lockgeom=0]]. FWIW, a value of '1' also fails.

This is based on OSL-v1.14.2.0 which goes dates back to September so it's possible this has been fixed?

Here's my example shader:

shader example(int face_idx = 0 [[int lockgeom = 0]],
               output color dst = 0)
{
    dst = color(face_idx * 0.25, 0, 0);
}

A patch to add the face_idx user-data to batched testshade:

diff --git a/src/testshade/batched_simplerend.cpp b/src/testshade/batched_simplerend.cpp
index ea2acbdf..6618fba7 100644
--- a/src/testshade/batched_simplerend.cpp
+++ b/src/testshade/batched_simplerend.cpp
@@ -21,6 +21,7 @@ struct UniqueStringCache {
         , red("red")
         , green("green")
         , blue("blue")
+        , face_idx("face_idx")
         , lookupTable("lookupTable")
         , blahblah("blahblah")
         , options("options")
@@ -51,6 +52,7 @@ struct UniqueStringCache {
     ustring red;
     ustring green;
     ustring blue;
+    ustring face_idx;
     ustring lookupTable;
     ustring blahblah;
     ustring options;
@@ -663,7 +665,17 @@ BatchedSimpleRenderer<WidthT>::get_userdata(ustringhash name,
 
     // For testing of interactions with default values
     // may not provide data for all lanes
-    if (name == ucache().s && Masked<float>::is(val)) {
+    if (name == ucache().face_idx && Masked<int>::is(val)) {
+        printf("found face_idx!\n");
+        Masked<int> out(val);
+        for (int i = 0; i < WidthT; ++i) {
+           if (out[i].is_on()) {
+               out[i] = int(4 * bsg->varying.u[i]);
+           }
+        }
+        return out.mask();
+    }
+    else if (name == ucache().s && Masked<float>::is(val)) {
         Masked<float> out(val);
         for (int i = 0; i < WidthT; ++i) {
             // NOTE: assigning to out[i] will mask by itself

Command line:
env TESTSHADE_BATCH_SIZE=16 testshade --batched --res 256 256 -o dst output.exr example

Here are the images I get:

With face_idx = 0 [[in lockgeom=0]] I get the wrong image:

Image

With face_idx = 2 [[in lockgeom=0]] I get the expected image:

Image

Is anyone able to reproduce this?

Thanks!

Ngôn ngữ chính
C++
Star
2.3k
Fork
415
Merge trung bình
2 ngày 10 giờ
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của AcademySoftwareFoundation/OpenShadingLanguage

Tất cả issue của AcademySoftwareFoundation/OpenShadingLanguage

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.