Documentation
¶
Overview ¶
Package rpc provides objects for distributed and parallel rendering
Index ¶
- func NewDispatcher() *gorpc.Dispatcher
- type ConcurrentRaytracer
- func (cr *ConcurrentRaytracer) GetImage() *hdrimage.Image
- func (cr *ConcurrentRaytracer) ParallelSamples() int
- func (cr *ConcurrentRaytracer) Sample(settings *SampleSettings) (*hdrimage.Image, error)
- func (cr *ConcurrentRaytracer) SetScene(scene *scene.Scene)
- func (cr *ConcurrentRaytracer) StoreSample(settings *SampleSettings) error
- type RemoteRaytracer
- func (rr *RemoteRaytracer) GetImage() *hdrimage.Image
- func (rr *RemoteRaytracer) LoadScene(data []byte) error
- func (rr *RemoteRaytracer) MaxRequestsAtOnce() (int, error)
- func (rr *RemoteRaytracer) MaxSamplesAtOnce() (int, error)
- func (rr *RemoteRaytracer) Sample(settings *SampleSettings) (*hdrimage.Image, error)
- func (rr *RemoteRaytracer) StoreSample(settings *SampleSettings) error
- type RemoteRaytracerCaller
- func (rrc *RemoteRaytracerCaller) GetImage() (*hdrimage.Image, error)
- func (rrc *RemoteRaytracerCaller) LoadScene(data []byte) error
- func (rrc *RemoteRaytracerCaller) MaxRequestsAtOnce() (int, error)
- func (rrc *RemoteRaytracerCaller) MaxSamplesAtOnce() (int, error)
- func (rrc *RemoteRaytracerCaller) Sample(settings *SampleSettings) (*hdrimage.Image, error)
- func (rrc *RemoteRaytracerCaller) StoreSample(settings *SampleSettings) error
- type SampleCounter
- type SampleSettings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDispatcher ¶
func NewDispatcher() *gorpc.Dispatcher
NewDispatcher returns only the dispatcher useful on the client, where you don't need the entire RemoteRaytracer
Types ¶
type ConcurrentRaytracer ¶
type ConcurrentRaytracer struct {
// contains filtered or unexported fields
}
ConcurrentRaytracer can render image samples on a scene in parallel, and has locks to ensure a maximum number of parallel renders. It can store samples internally, and they can be collected on demand.
func NewConcurrentRaytracer ¶
func NewConcurrentRaytracer( parallelSamples int, scene *scene.Scene, seed int64, ) *ConcurrentRaytracer
NewConcurrentRaytracer creates a concurrent raytracer with parallelSamples allowed number of parallel operations
func (*ConcurrentRaytracer) GetImage ¶
func (cr *ConcurrentRaytracer) GetImage() *hdrimage.Image
GetImage collects all samples up to this moment (and waits for those that are currently being rendered to finish), and merges them. StoreSample() can be called during calling this function, and will block until it finishes. Next samples will start from zero (e.g. the base image is reset)
func (*ConcurrentRaytracer) ParallelSamples ¶
func (cr *ConcurrentRaytracer) ParallelSamples() int
ParallelSamples returns the number of allowed parallel samples
func (*ConcurrentRaytracer) Sample ¶
func (cr *ConcurrentRaytracer) Sample(settings *SampleSettings) (*hdrimage.Image, error)
Sample works like StoreSample(), but instead of storing the image internally, returns a new image.
func (*ConcurrentRaytracer) SetScene ¶
func (cr *ConcurrentRaytracer) SetScene(scene *scene.Scene)
SetScene sets a new scene, resetting the state of the raytracer
func (*ConcurrentRaytracer) StoreSample ¶
func (cr *ConcurrentRaytracer) StoreSample(settings *SampleSettings) error
StoreSample renders the scene into an internal image. You can (and should) call it multiple times, in parallel, and when you're finished you can get the merged samples with GetImage(). StoreSample will block if the parallel calls exceed the parallelSamples value, and wait for other samples to finish.
type RemoteRaytracer ¶
type RemoteRaytracer struct { Raytracer *ConcurrentRaytracer Requests int Dispatcher *gorpc.Dispatcher Samples int }
RemoteRaytracer represents a remote raytracer and a dispatcher. It can be used in a client/server environment with gorpc.
func NewRemoteRaytracer ¶
func NewRemoteRaytracer( randomSeed int64, threads int, maxRequestsAtOnce int, samplesAtOnce int, ) *RemoteRaytracer
NewRemoteRaytracer initialises the remote raytracer object
func (*RemoteRaytracer) GetImage ¶
func (rr *RemoteRaytracer) GetImage() *hdrimage.Image
GetImage returns the combined result of any previously stored samples
func (*RemoteRaytracer) LoadScene ¶
func (rr *RemoteRaytracer) LoadScene(data []byte) error
LoadScene loads a scene
func (*RemoteRaytracer) MaxRequestsAtOnce ¶
func (rr *RemoteRaytracer) MaxRequestsAtOnce() (int, error)
MaxRequestsAtOnce returns the maximum number of requests allowed to the worker at the same time
func (*RemoteRaytracer) MaxSamplesAtOnce ¶
func (rr *RemoteRaytracer) MaxSamplesAtOnce() (int, error)
MaxSamplesAtOnce returns the number of samples the worker might render at once
func (*RemoteRaytracer) Sample ¶
func (rr *RemoteRaytracer) Sample(settings *SampleSettings) (*hdrimage.Image, error)
Sample samples an image and returns it
func (*RemoteRaytracer) StoreSample ¶
func (rr *RemoteRaytracer) StoreSample(settings *SampleSettings) error
StoreSample stores samples an image without returning it, to be used with a later call of GetImage()
type RemoteRaytracerCaller ¶
type RemoteRaytracerCaller struct {
// contains filtered or unexported fields
}
RemoteRaytracerCaller is a wrapper for calling RemoteRaytracer methods through RPC.
func NewRemoteRaytracerCaller ¶
func NewRemoteRaytracerCaller(address string, timeout time.Duration) *RemoteRaytracerCaller
NewRemoteRaytracerCaller initializes the wrapper, connecting to a worker
func (*RemoteRaytracerCaller) GetImage ¶
func (rrc *RemoteRaytracerCaller) GetImage() (*hdrimage.Image, error)
GetImage retreives the combined result of any previously stored samples
func (*RemoteRaytracerCaller) LoadScene ¶
func (rrc *RemoteRaytracerCaller) LoadScene(data []byte) error
LoadScene sends a scene to the worker
func (*RemoteRaytracerCaller) MaxRequestsAtOnce ¶
func (rrc *RemoteRaytracerCaller) MaxRequestsAtOnce() (int, error)
MaxRequestsAtOnce gets the worker's desired maximum simoultaneous requests
func (*RemoteRaytracerCaller) MaxSamplesAtOnce ¶
func (rrc *RemoteRaytracerCaller) MaxSamplesAtOnce() (int, error)
MaxSamplesAtOnce gets the worker's desired samples to request at once
func (*RemoteRaytracerCaller) Sample ¶
func (rrc *RemoteRaytracerCaller) Sample(settings *SampleSettings) (*hdrimage.Image, error)
Sample waits for the worker to sample an image, retreives it and returns it
func (*RemoteRaytracerCaller) StoreSample ¶
func (rrc *RemoteRaytracerCaller) StoreSample(settings *SampleSettings) error
StoreSample waits for the worker to sample an image, storing it worker-side
type SampleCounter ¶
type SampleCounter struct {
Counter int64
}
SampleCounter is a thread-safe decreasing counter
func NewSampleCounter ¶
func NewSampleCounter(value int) *SampleCounter
NewSampleCounter initializes the counter with a value
func (*SampleCounter) Dec ¶
func (sc *SampleCounter) Dec(value int) int
Dec decreases the counter by value, but doesn't go below zero (if value > sc.value, the counter's value will become 0). Returns the actual amount decremented (so the return value is 0 if the counter has already been 0)
type SampleSettings ¶
SampleSettings contains parameters for making a sample