Skip to content

Commit

Permalink
Some more work on this but it's still not good and I don't know why
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Oct 12, 2023
1 parent 59e35ab commit 4f867f5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
18 changes: 4 additions & 14 deletions incremental-loader.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
;; We don't care about actual staging, so just stage immediately.
(stage dependency op))

(defmethod restage (object (op load-op))
(setf (gethash object (staged op)) NIL)
(stage object op))

(defmethod stage :before (object (op load-op))
(when (eql :tentative (gethash object (staged op)))
(error "Circular staging on ~a!" object))
Expand All @@ -43,25 +47,11 @@
(for:for ((child over container))
(stage child op)))

;;; This is pretty hacky.
(defmethod stage :after ((renderable renderable) (op load-op))
(loop for observer in (gethash 'renderable (observers op))
do (observe-load-state observer renderable :staged op)))

(defmethod stage :after ((pass per-object-pass) (op load-op))
(register-load-observer op pass 'renderable))

(defmethod observe-load-state ((pass per-object-pass) (renderable renderable) state (op load-op))
(let ((program (enter renderable pass)))
(when program (stage program op))))

(defmethod stage ((object resource) (op load-op))
(v:info :test "~a" object)
(allocate object)
(change-state op object :allocated))

(defmethod stage ((object asset) (op load-op))
(v:info :test "~a" object)
(load object)
(change-state op object :loaded))

Expand Down
7 changes: 4 additions & 3 deletions resources/vertex-array.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
(setf (index-buffer array) index-buffer)))

(defmethod dependencies ((array vertex-array))
(append (call-next-method)
(if (index-buffer array) (list (index-buffer array)))
(mapcar #'unlist (bindings array))))
(delete-duplicates
(append (call-next-method)
(if (index-buffer array) (list (index-buffer array)))
(mapcar #'unlist (bindings array)))))

(defun update-array-bindings (array bindings &optional index)
(gl:bind-vertex-array (data-pointer array))
Expand Down
29 changes: 21 additions & 8 deletions shader-pass.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,16 @@
(finalize (framebuffer pass))))

(defmethod enter ((container container) (pass shader-pass))
(when (next-method-p)
(call-next-method))
(sequence:dosequence (object container)
(enter object pass)))
(prog1 (when (next-method-p)
(call-next-method))
(sequence:dosequence (object container)
(enter object pass))))

(defmethod leave ((container container) (pass shader-pass))
(when (next-method-p)
(call-next-method))
(for:for ((object over container))
(leave object pass)))
(prog1 (when (next-method-p)
(call-next-method))
(for:for ((object over container))
(leave object pass))))

(defmethod render (object (pass shader-pass))
(render object (shader-program-for-pass pass object)))
Expand Down Expand Up @@ -410,6 +410,19 @@
(defmethod render-with ((pass shader-pass) object program)
(render object program))

;;; This is pretty hacky.
(defmethod stage :after ((renderable renderable) (op load-op))
(loop for observer in (gethash 'renderable (observers op))
do (observe-load-state observer renderable :staged op)))

(defmethod stage :after ((pass per-object-pass) (op load-op))
(register-load-observer op pass 'renderable))

(defmethod observe-load-state ((pass per-object-pass) (renderable renderable) (state (eql :staged)) (op load-op))
(let ((program (enter renderable pass)))
(when program
(stage program op))))

(define-shader-pass single-shader-pass ()
((shader-program :accessor shader-program)))

Expand Down

0 comments on commit 4f867f5

Please sign in to comment.